我有下面的代码调用链接,它以json
结构返回一些信息:
DECLARE
@Object INT,
@vResponseText varchar(8000),
@CountryInfo varchar(8000),
@GetCountryRequest AS varchar(8000)=
'{
"userName":"200900119",
"password":"8481774916"
}'
EXEC sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUTPUT
EXEC sp_OAMethod @Object, 'Open', NULL, 'POST', 'https://api.dpd.ro/v1/location/country/642', 'false'
EXEC sp_OAMethod @Object, 'SETRequestHeader', null, 'Content-Type', 'application/json'
EXEC sp_OAMethod @Object, 'Send', NULL, @GetCountryRequest
EXEC sp_OAMethod @Object, 'responseText', @vResponseText OUTPUT
EXEC sp_OADestroy @Object
PRINT @vResponseText
到目前为止一切顺利!如果我想将响应插入表中,然后使用JSON_QUERY
来处理数据,则需要使用GetProperty方法将其插入表中(在我的情况下为全局时态表),该方法不起作用
IF OBJECT_ID('tempdb.dbo.##CountryTable', 'U') IS NOT NULL
BEGIN
DROP TABLE ##CountryTable
END
CREATE TABLE ##CountryTable(
CountryInfo varchar(8000)
)
INSERT ##CountryTable (CountryInfo)
EXEC sp_OAGetProperty @Object, 'responseText'
EXEC sp_OADestroy @Object
我想念什么?谢谢