Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
437 views
in Technique[技术] by (71.8m points)

Getting blank response while making API call from SQL Server

I have one working batch file which makes API call and download the response file. Now, I want to make API call from SQL server instead of using that batch file.

Bach file has following code:

curl -H "X-API-KEY:CDK5fvQodogejk1SFERTGSlbTJivgYNKuZHqyjEFl6zoyHdk8dBcw712Vwf"  https://app.guide.com/external/api/v1/bookings?from_date="2020-10-01"?to_date="2030-12-31" -o "\LSRSQL01ShareWorkingFoldersLUXCAnyRoadRoad_JSON.txt"

T-SQL Code as below:

DECLARE @Object AS INT;
DECLARE @ResponseText AS VARCHAR(8000);


EXEC sys.sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
EXEC sys.sp_OAMethod @Object,
                     'open',
                     NULL,
                     'get',
                     'https://app.guide.com/external/api/v1/bookings?from_date=2020-10-01?to_date=2030-12-31',
                     'false';
EXEC sys.sp_OAMethod @Object,
                     'setRequestHeader',
                      NULL,
                     'X-API-KEY:CDK5fvQodogejk1SFERTGSlbTJivgYNKuZHqyjEFl6zoyHdk8dBcw712Vwf';
EXEC sys.sp_OAMethod @Object, 'send';
EXEC sys.sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT;

SELECT @ResponseText;

EXEC sys.sp_OADestroy @Object;

while running above code I'm getting blank response.

question from:https://stackoverflow.com/questions/65891652/getting-blank-response-while-making-api-call-from-sql-server

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...