# API Distance Matrix does not work on thunkable x

**URL:** https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596
**Category:** Questions about Thunkable X
**Created:** [February 17, 2021, 4:22am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596 "2021-02-17T04:22:37Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)
#### Post date: [February 17, 2021, 4:22am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/1 "2021-02-17T04:22:37Z")

</div>

Hi Everyone,

I am trying to get the “distance” and the “duration” from google maps distance matrix API, but it is not working. The blocks are shown below:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/b/eb505da780a56394b1ee7afb8b4e91cc58169763.png)

On the browser, it works:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/6/a61fdf72e7592ef7e6f17ebb16d079e86e00ade3.png)

I get the “200” status, but:

On IOS and Android test I get this error message:

 ![WhatsApp Image 2021-02-17 at 01.18.33](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/3/a3d395f38b1e25a31a366f5519171d1359ac4ab3.jpeg)

I think is a thunkable error… can someone help me please?  
Thank you so much!

---

<div class="post-metadata">

### Author: ![Deluxe](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/deluxe/32/30016_2.png) [@Deluxe](https://community.thunkable.com/u/Deluxe)
#### Post date: [February 17, 2021, 4:31am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/2 "2021-02-17T04:31:42Z")

</div>

I am not familiar with the specific API but I wonder why you first post before you get. Is that necessary?

---

<div class="post-metadata">

### Author: ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)
#### Post date: [February 17, 2021, 4:35am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/3 "2021-02-17T04:35:20Z")

</div>

I actually dont know much about html, but I tried only with POST, only with GET and both and with all I got the same result ☹

---

<div class="post-metadata">

### Author: ![Deluxe](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/deluxe/32/30016_2.png) [@Deluxe](https://community.thunkable.com/u/Deluxe)
#### Post date: [February 17, 2021, 4:39am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/4 "2021-02-17T04:39:26Z")

</div>

I don’t think you need the Get block. Also, I am a bit sceptical about the way you handle the response. Can you please paste the JSON response in plain text here (not as image) for me to test something? Thanks.

---

<div class="post-metadata">

### Author: ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)
#### Post date: [February 17, 2021, 4:47am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/5 "2021-02-17T04:47:47Z")

</div>

Ok, I will take it out the GET block then. Thank you for answering! It’s here:

{  
“destination\_addresses” : [“Nova Iorque, NY, EUA”],  
“origin\_addresses” : [“Washington, D.C., Distrito de Columbia, EUA”],  
“rows” : [  
{  
“elements” : [  
{  
“distance” : {  
“text” : “367 km”,  
“value” : 367440  
},  
“duration” : {  
“text” : “3 horas 49 minutos”,  
“value” : 13721  
},  
“status” : “OK”  
}  
]  
}  
],  
“status” : “OK”  
}

---

<div class="post-metadata">

### Author: ![Deluxe](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/deluxe/32/30016_2.png) [@Deluxe](https://community.thunkable.com/u/Deluxe)
#### Post date: [February 17, 2021, 4:58am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/6 "2021-02-17T04:58:27Z")

</div>

Try this. A more traditional approach. No need to convert the object to JSON as your response is JSON in first place. You need to convert it the other way around actually using the “get object from JSON” block. Give it a go:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/4/244beb7ab1060cbb4eac1adc7b2a575ec4956244.png)

Also, start using this tool. It will help you with identifying the paths to the information you need in JSON responses:

[https://jsonpathfinder.com](https://jsonpathfinder.com)

---

<div class="post-metadata">

### Author: ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)
#### Post date: [February 17, 2021, 6:13am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/7 "2021-02-17T06:13:48Z")

</div>

Thank you so much for answering me! However, I am still getting the same message: “something has gone wrong. Check your blocks and reset this page” ☹

I don’t know if I do need to set headers like authentication and Bearer acess token key or something like that. I did not put anything on headers.

---

<div class="post-metadata">

### Author: ![Deluxe](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/deluxe/32/30016_2.png) [@Deluxe](https://community.thunkable.com/u/Deluxe)
#### Post date: [February 17, 2021, 6:32am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/8 "2021-02-17T06:32:20Z")

</div>

Can you please share your project link and PM me your API key for me to test? Thanks

---

<div class="post-metadata">

### Author: ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)
#### Post date: [February 17, 2021, 12:39pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/9 "2021-02-17T12:39:02Z")

</div>

I sent to you on private! Thank you 🙂

---

<div class="post-metadata">

### Author: ![Deluxe](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/deluxe/32/30016_2.png) [@Deluxe](https://community.thunkable.com/u/Deluxe)
#### Post date: [February 17, 2021, 1:11pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/10 "2021-02-17T13:11:06Z")

</div>

Two mistakes:

1. You still do a POST instead of a GET API call
2. You convert the response to JSON thinking it is an object. The response is JSON as it comes so no need to convert it again to JSON. Thinking that it is an object and converting it to JSON may cause the app to crash.

I mentioned both of the above points in my previous message. Here is the corrected code:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/0/90a8148e0b880368660741b783213eaefa8592f1.png)

---

<div class="post-metadata">

### Author: ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)
#### Post date: [February 17, 2021, 4:19pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/11 "2021-02-17T16:19:06Z")

</div>

Thank you so much!!! It worked!

---

<div class="post-metadata">

### Author: ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)
#### Post date: [May 3, 2021, 10:37am UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/12 "2021-05-03T10:37:30Z")

</div>

Hi!!

Do you know why this code does not work on web app?

When I published my web app, I got this error message: “the website or service provider you are trying to reach does not support HTTPS requests”

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [May 3, 2021, 12:31pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/13 "2021-05-03T12:31:30Z")

</div>

Most API calls do not work on the web app. Yours is just one of those.

---

<div class="post-metadata">

### Author: ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)
#### Post date: [May 25, 2021, 11:01pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/14 "2021-05-25T23:01:04Z")

</div>

Hi! thank you for answering it. But it says here on the documentation from the API that "  
HTTPS is recommended whenever possible, and is required for applications that include sensitive user data - such as a user’s location - in requests.If HTTPS is not possible, to access the Distance Matrix API over HTTP, use: **http** ://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters

> **[Overview  |  Distance Matrix API  |  Google Developers](https://developers.google.com/maps/documentation/distance-matrix/overview)**
>
> Calculate travel distance and time between a number of points using the Google Maps API. Find out about usage limitations and how to get a key to get started.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [May 25, 2021, 11:10pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/15 "2021-05-25T23:10:44Z")

</div>

Yes, Google can recommend/require HTTPS but that doesn’t mean that Thunkable can support it as a web app.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [November 10, 2022, 5:53pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/17 "2022-11-10T17:53:16Z")

</div>

Please don’t post in multiple topics.

---

<div class="post-metadata">

### Author: ![krishanveer.gangwars](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@krishanveer.gangwars](https://community.thunkable.com/u/krishanveer.gangwars)
#### Post date: [November 10, 2022, 6:17pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/18 "2022-11-10T18:17:22Z")

</div>

ok sorry

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [November 10, 2022, 6:25pm UTC](https://community.thunkable.com/t/api-distance-matrix-does-not-work-on-thunkable-x/1102596/19 "2022-11-10T18:25:50Z")

</div>


