2017-03-03 82 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,它不正確的事情:

檢索響應實體正文文本。