So, I am a dabbler, and have been asked to help out at work.We have an API that delivers a JSON file. I need to be able to populate a table in SQL with the JSON data through a sp if possibleThe URL is http://servername/api/rest/22,23,24?date=2016-09-23and the output is [{"agentId":22,"firstName":"AGENT1","lastName":"AGNET","scheduleAdherence":98.0,"scheduleConformity":100.0},{"agentId":23,"firstName":"AGENT2","lastName":"AGNET2","scheduleAdherence":98.0,"scheduleConformity":99.0},{"agentId":24,"firstName":"AGENT3","lastName":"AGNET3","scheduleAdherence":97.0,"scheduleConformity":102.0}]I have tried the following but my response is always blank[code="sql"]Declare @Object as Int;Declare @ResponseText as Varchar(8000);Declare @Body as varchar(8000);Exec sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUT;EXEC sp_OAMethod @Object, 'open', NULL, 'post','http://servername/api/rest/22,23,24?date=2016-09-23', 'false'Exec sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Type', 'application/json'Exec sp_OAMethod @Object, 'send', null, @bodyExec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUTSelect @ResponseText [response]Exec sp_OADestroy @Object[/code]
↧