there are two common approaches to build a web query api to sqlserver
first is odata:
second is graphql:
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
there are two common approaches to build a web query api to sqlserver
first is odata:
second is graphql:
SQL Server is a database server, not an application server. Better search for a solution outside SQL Server, e.g. a solution with PowerScript.
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.
$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