get JSON from secure HTTP

All, I’m trying to get the list of supported google languages in a listbox.

When I open “https://www.googleapis.com/language/translate/v2/languages?key=mycodehere” in my web browser, I get the reply I need:

{ "data": { "languages": [ { "language": "af" }, { "language": "ar" }, { "language": "az" } ] } }

there is more but I cut some languages out of this paste.

In XOJO I try to get this data in a JSON object.

  Dim http As New HTTPSecureSocket
  Dim key As String
  key= "mycodehere"
    http.SetRequestHeader("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0")
  Dim socket1 As New HTTPSocket
  Dim jsonData As String = socket1.Get("https://www.googleapis.com/language/translate/v2/languages?key="+key, 30)

In my debug window I see jsonData contains this:
{“error”:{“errors”:[{“domain”:“global”,“reason”:“sslRequired”,“message”:“SSL is required to perform this operation.”}],“code”:403,“message”:“SSL is required to perform this operation.”}}

Could someone help me to understand what is wrong?

thanks

gert

I’m WAY not an expert, but have you tried changing socket1 to a New HTTPSecureSocket, and then put socket1.secure=true after the dim?

Bingo! That did the trick?

thanks.

Boom!! Nice one Bill! :slight_smile:

For the future, in case you want to extract data from API’s, json-csv.com is a good tool for this. You just paste in the API URL and then download a spreadsheet with all the data.