Hi everyone,
My aim is to connect to web api via MSSQL and post data. I'm looking for such an example, I couldn't find a proper example.
Could you please help with such a simple example.
Hi AliYilmaz,
Refer below article.
Hi Dharmendr,
It was misunderstood. I need to do this with the stored procedure in sql management. I will do it with tsql.
Refer below query.
SQL
Declare @Object as Int; Declare @ResponseText as Varchar(8000); Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT; Exec sp_OAMethod @Object, 'open', NULL, 'get', 'API_Url', 'false' Exec sp_OAMethod @Object, 'send' Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT Select @ResponseText Exec sp_OADestroy @Object
Reference:
https://stackoverflow.com/questions/22067593/calling-an-api-from-sql-server-stored-procedure/52686957
I need to add content type json in the header.
I need to add username and password to this code. As a parameter to the body part.
Please try to follow below Link.
https://www.zealousweb.com/calling-rest-api-from-sql-server-stored-procedure/
https://www.sqlshack.com/how-to-parse-json-in-sql-server/
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.