How to call .net core Web API in sql server?
I tried below then i getting "0x800C0005", "The system cannot locate the resource specified."
DECLARE @Object AS INT ;
DECLARE @hResult INT
DECLARE @Url AS VARCHAR(1000) ;
declare @statusText varchar(1000), @status varchar(1000), @ResponseText AS VARCHAR(8000) ;
SET @Url = 'https://myhost.com/path/to/whatever/'
EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT ; --
EXEC sp_OAMethod @Object, 'open', NULL, 'get', @Url,'false'
EXEC sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-type', 'application/json';
EXEC @hResult = sp_OAMethod @Object, 'send';
exec sp_OAGetProperty @Object, 'StatusText', @statusText out
exec sp_OAGetProperty @Object, 'Status', @status out
EXEC sp_OAGetProperty @Object, 'responseText', @ResponseText OUTPUT
Try with below sample code
Declare @Object as Int;
Declare @ResponseText as Varchar(8000);
Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'get', 'https://myhost.com/path/to/whatever/', 'false'
Exec sp_OAMethod @Object, 'send'
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
Select @ResponseText
User contributions licensed under CC BY-SA 3.0