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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…