I have a problem with Web API

Hi,

I’ve tried to get the response from my customer Web API with the blocks depicted below, but the error is always “The website or service provider you are trying to reach does not support HTTPS requests.” (or “undefined” on Live Test). It would be great if someone can help me get through this.


Thanks in advance.
Jack.

1 Like

Hi,

Test everything only in Live on your devices.

1 Like

Hi,
Thanks for your advice. I already did, but it changed the error message from “The website or service provider you are trying to reach does not support HTTPS requests.” to “undefined”.

@jackratchaburi70120f

Does this api call work in Postman?

1 Like

Hi Jared,

Yes, I tested it with Postman, VBA, and also https://reqbin.com/.
Here is the code I use to call the API successfully.

Dim xmlhttp As Object
Dim myurl As String

Set xmlhttp = CreateObject(“WinHttp.WinHttpRequest.5.1”)

myurl = “http://a.b.c.d/ServiceQuick/ServiceQuick.php?Service=ShowInfo

xmlhttp.Open “POST”, myurl, False
xmlhttp.setRequestHeader “Content-Type”, “application/json”

xmlhttp.send “{”“token”":"“xxxx”","“idno”":"“xxxx”"}"

Output = xmlhttp.responseText

Jack.

This means that you are making the request incorrectly. POST in Thuinkable X works well with https when I make different requests.

Look carefully at your blocks. You always display the value of the error block when there is an error and when there is no error. Simply put, the response from the server is not output anywhere.

2 Likes

@actech
You are absolutely right!
There are two conditions needed to done at the same time:

  1. Test must be done on device only.
  2. I did wrong at the status checking.
    Thank you very much.

Hi there! I am having the same issue with another Web API (Google distance matrix). When I try on live device, it works well. But when I try on web app, it says the same error “the website…”. The problem is that my app will be a web app.

What did you do wrong on status? Because I also put this “If status = 200” block.

This problem is individual to certain APIs. I don’t believe you’re going to be able to force an API that doesn’t work as a web app to work. I don’t understand the technical reasons for this but I’ve come to accept it.

What I did for measuring distances is to use the Haversine formula and create the math for it in Thunkable. It takes a ton of blocks to do but it works really fast and really well.

Tatian

1 Like