Where can I find resources on how to use invoke-webrequest with SQL Server?

Mudit Gupta 81 Reputation points
2023-10-17T18:54:44.3233333+00:00

I am trying to find learning resources on how to use invoke-webrequest with SQL server. I want to push SQL server query data to a website. I am looking for some primer or 101 on basic concepts related to it.

Thanks

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,737 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,068 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,526 Reputation points
    2023-10-17T19:48:28.8266667+00:00

    there are two common approaches to build a web query api to sqlserver

    first is odata:

    https://learn.microsoft.com/en-us/odata/webapi-8/getting-started?tabs=net60%2Cvisual-studio-2022%2Cvisual-studio

    second is graphql:

    https://github.com/graphql-dotnet/graphql-dotnet

    0 comments No comments

  2. Olaf Helper 40,816 Reputation points
    2023-10-18T05:27:58.22+00:00

    SQL Server is a database server, not an application server. Better search for a solution outside SQL Server, e.g. a solution with PowerScript.


  3. Mudit Gupta 81 Reputation points
    2024-04-17T18:35:24.3833333+00:00

    Just sharing so if anyone is looking for solution, this might be helpful.

    For my case, data was not too much. Just 500 rows at a time. Data is sitting on SQL server. I created a powershell script to push data. Then I used cursor to populate data for each row into a powershell script.

    Next, I saved this file on OS and run it from powershell.

    0 comments No comments

  4. Mudit Gupta 81 Reputation points
    2024-04-17T18:40:41.0866667+00:00
    $Uri = 'URL'
    $Body = @{     
    	u_parameter1  = 'value1'
        u_parameter2  = 'value2'
        u_parameter2  = 'value3'
        } | ConvertTo-Json
    
    $Headers= @{"Accept"="application/json" 
    "Content-Type"="application/json"
    }
    
    $svc_pwd=ConvertTo-SecureString "PASSWORD" -AsPlainText -Force
    $svc_cred = New-Object Management.Automation.Pscredential ( 'USERNAME', $svc_pwd)
    $Result = Invoke-RestMEthod -Uri $Uri -headers $Headers -Method Post  -Body $Body -Credential $svc_cred | Out-File -FilePath FILEPATH\ResultLog.csv -Append -width 300
    
    
    0 comments No comments