August 1, 2020 at 4:08 pm
Greetings,
I have a need to call a rest api against a resource. It a POST and would like to send the following as POST option
http.post(url,
'{
"https": { rejectUnauthorized: settings.ssl },
"headers": {
"Authorization": "BASIC dfsdkfdsfyduyfiuhdfiuyu5y43=",
"Content-Type": "application/json",
"Accept": "application/json"
}
}'
)
Tried to this but it fails
EXEC @ret = sp_OAMethod @token, 'open', NULL, 'POST', @url, 'false';
EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'Authentication', @authHeader;
EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'Content-type', @contentType;
EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'https', '{"rejectUnauthorized":"false"}';
EXEC @ret = sp_OAMethod @token, 'send', NULL, null;
August 2, 2020 at 4:10 pm
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
September 13, 2020 at 12:24 pm
You could probably add some more details, like what's exactly failing etc.
According to https://stackoverflow.com/questions/24118508/how-can-i-pass-a-body-from-stored-procedure-to-a-rest-service/38185814 it should be possible so you probably messed up the call
August 12, 2021 at 8:06 pm
Can someone help.... i am getting a null response. if you pass the actual URL u do get a JSON back. Waht am i doing so wrong.....the HTTP gods are going against me!
Declare @Object as Int;
Declare @ResponseText as Varchar(8000);
Declare @Body as varchar(8000) =
'{
"Subsystem": 1,
"Exception": "",
"Message": "I have done what you asked",
"Time": "2014-06-09T11:16:35",
"Attribute": { "Number of attempts": "0" }
}'
Exec sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUT;
EXEC sp_OAMethod @Object, 'open', NULL, 'get','https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=32277993', '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
Sandeep Kataria
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy