2017-03-03 76 views
0

首先,GET,我看着就已经SO在这里发现了一个类似的问题:使用REST在传统的ASP

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到屏幕上,并复制&其粘贴到浏览器中,我得到了正确的输出正确的信息。 A json -formatted对象与我需要的信息。

但是,如果我打印http.responseBody,它只是产生了一些中国的字符是这样的:

佄呃偙⁅呈䱍倠䉕䥌⁃ჲ⼯㍗⽃䐯䑔䠠䵔⁌⸴㄰吠慲狝莹潩虑⽬䔯≎∠瑨灴⼺眯睷眮⸳牯⽧剔栯浴㑬氯浔敳搮摴㸢਍πⴭ䐠瑡楥虑敭>敤慦汵⹴獡⁰㉖〮‰㠰〮⸸〲㈱䠠湡⵳楗汬墙楥敢杲牥ჰ

我在做什么错?链接是正确的。我也尝试添加:

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

没有成功

回答

0

好,因为事实证明,使用responseBody是不正确的。根据MSDN-Page为WinHttpRequest,responseBody被检索此:

检索响应实体体为无符号字节数组。

就我而言,我不得不切换到reponseText,它不正确的事情:

检索响应实体正文文本。