我正在調用外部API。令人討厭的是,它返回的數據位於標題中(文本響應爲空)。如何在Http請求中訪問響應頭
如何訪問響應的標題?
這就是我想:
Dim httpRequest, postResponse
Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpRequest.Open "POST", "http://www.api.com", False, "un", "pw"
httpRequest.SetRequestHeader "Content-Type", "application/json"
httpRequest.setRequestHeader "Content-Length", len(jsondata)
httpRequest.Send data
if httpRequest.status = 200 then
response.write httpRequest.getResponseHeader
response.write httpRequest.ResponseText
end if
Set httpRequest = nothing
但它給我:
msxml3.dll error '80072f76'
The requested header was not found
和獎金的問題:我只注意到 「MSXML2.ServerXMLHTTP」 的 「XML」 部分 - 我使用正確的協議嗎?它一直用於直接的帖子,直到現在。
是不是你缺少你想要檢索哪個頭?又名'httpRequest.getResponseheader(「服務器」)'[如圖所示](http://msdn.microsoft.com/en-us/library/windows/desktop/ms765415(v = vs.85).aspx) – rene