在经典中使用 REST 的 GET asp

using REST's GET in classic asp

首先,我已经看过 SO 并在这里发现了一个类似的问题:

Calling REST web services from a classic asp page

但是,这并不能解决我的问题。我找不到方法来检索我的电话提供的正确信息

function determineLocationId(identifier)    

    Dim http: Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
    Dim privateKey
    privateKey = "myKey"

    IdentifyUrl = "https://sandbox.uberall.com/api/locations/?identifier=" & identifier & "&private_key=" & privateKey
    With http
      Call .Open("GET", identifyUrl, False)
      Call .Send()
    End With
    If Left(http.Status, 1) = 2 Then
      response.write("updated")
    Else
      'Output error
      Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
    End If

    response.write(identifyUrl)
    response.end()

    determineLocationId = identifier
end function

当我将 identifyUrl 打印到屏幕上并将其复制并粘贴到我的浏览器中时,我得到了正确的输出。包含我需要的信息的 json 格式的对象。

然而,如果我打印 http.responseBody,它只会产生一些像这样的中文字符:

佄呃偙⁅呈䱍倠䉕䥌⁃ⴢ⼯㍗⽃䐯䑔䠠䵔⁌⸴㄰吠慲獮瑩潩慮⽬䔯≎∠瑨灴⼺眯睷眮⸳牯⽧剔栯浴㑬氯潯敳搮摴㸢਍ℼⴭ䐠瑡楥慮敭›敤慦汵⹴獡⁰㉖〮‰㠰〮⸸〲㈱䠠湡⵳楗汬⁩牆楥敢杲牥ⴠ

我做错了什么? link 绝对是正确的。我还尝试添加:

Call .SetRequestHeader("Content-Type", "application/json")

没有成功

好吧,事实证明,使用 responseBody 是不正确的。根据 WinHttpRequest 的 MSDN-PageresponseBody 正在检索:

Retrieves the response entity body as an array of unsigned bytes.

在我的例子中,我不得不切换到 reponseText,它做了正确的事情:

Retrieves the response entity body as text.