Excel 2010 VBA - 尝试使用 API JSON 从站点检索数据

时间:2021-01-12 21:21:44

标签: json excel vba api

在此先感谢您的帮助!!第一次使用 api 调用。尝试将 ISBN 输入到一个单元格中,从我位于 artofbooks.com 的库存文件中检索信息 他们的 API 调用文档并不是那么好。这是我的代码,我收到“错误令牌”错误。

 sub test
    creds = EncodeBase64("{ AOB_AUTH_USER : cottagebooks, AOB_AUTH_PW : xxxxxx }")
    isbn = Cells(5, 3).Value
   
    
    Set objHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    URL = "https://www.theartofbooks.com/api/2.0/item=2010101257"
    objHttp.Open "GET", URL, False
    objHttp.SetRequestHeader "Content-Type", "multipart/form-data"
    objHttp.SetRequestHeader "Accept", "application/xml"
    objHttp.SetRequestHeader "Authorization:", "Bearer " & creds
    
    objHttp.Send
    strResponseStatus = objHttp.Status
    strresponsetext = objHttp.ResponseText
    strresponsetext = CStr(strresponsetext)
         
   MsgBox strresponsetext
end sub

0 个答案:

没有答案
相关问题