0

First of all, I looked on SO already and found a similar question here:

Calling REST web services from a classic asp page

However, this doesn't solve my problem. I can't find a way to retrieve the correct information provided by my call

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

When I print my identifyUrl to the screen and copy & paste it into my browser, I get the correct output. A json-formatted object with the information I need.

However, if I print http.responseBody, it just yields some chinese chars like this:

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

What am I doing wrong? The link is definetly the correct one. I also tried to add:

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

without success

Community
  • 1
  • 1
DasSaffe
  • 2,080
  • 1
  • 28
  • 67

1 Answers1

1

Well, as it turned out, using responseBody wasn't correct. According to the MSDN-Page for WinHttpRequest, responseBody is retrieving this:

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

In my case, I had to switch to reponseText, which does the correct thing:

Retrieves the response entity body as text.

DasSaffe
  • 2,080
  • 1
  • 28
  • 67