Last active
March 15, 2025 03:16
-
-
Save theorigin/fa3c58406ff7b4565ca2 to your computer and use it in GitHub Desktop.
SQL Server code to POST to an API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Object AS INT; | |
DECLARE @ResponseText AS VARCHAR(8000); | |
DECLARE @Body AS VARCHAR(8000) = | |
'{ | |
"what": 1, | |
"ever": "you", | |
"need": "to send as the body" | |
}' | |
EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT; | |
EXEC sp_OAMethod @Object, 'open', NULL, 'post','http://requestb.in/1h83e3n1', 'false' | |
EXEC sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Type', 'application/json' | |
EXEC sp_OAMethod @Object, 'send', null, @body | |
EXEC sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT | |
SELECT @ResponseText | |
EXEC sp_OADestroy @Object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this repository, you helped me a lot! :) I just wondering how I add an API token? In body?