# \[Solved\] Connecting to an API

**URL:** https://community.thunkable.com/t/solved-connecting-to-an-api/1197557
**Category:** Questions about Thunkable X
**Tags:** solved
**Created:** [March 15, 2021, 6:40pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557 "2021-03-15T18:40:10Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![jmrchy](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@jmrchy](https://community.thunkable.com/u/jmrchy)
#### Post date: [March 15, 2021, 6:40pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/1 "2021-03-15T18:40:10Z")

</div>

Hey,

Web\_api works only for some rare URL. The problem is present with Tunkable live on ANDROID 10 (Network request failed), but not with ANDROID 9 live and generated apk.

The following example shows one working url (public IP api) and one not working (public CLOCK api) :

[https://x.thunkable.com/copy/904b56457ad38ae27254a10d7cab7246](https://x.thunkable.com/copy/904b56457ad38ae27254a10d7cab7246)

Thanks for your help.  
JM ROuchy

---

<div class="post-metadata">

### Author: ![ronturcotte](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@ronturcotte](https://community.thunkable.com/u/ronturcotte)
#### Post date: [March 15, 2021, 8:27pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/2 "2021-03-15T20:27:57Z")

</div>

I’m having issues with the web API as well - even when using the app from a Thunkable tutorial (Countries Info App).

Whether I use Preview online or Live, the app crashes whenever I enter a country name and press the search button. In Preview, the screen just goes blank. In the Live app, it just returns “Something has gone wrong. Check your blocks and reset this page.” If I output the response, status and error data to a label, I get a blank response, a blank status and an error that says “The website or service provider you are trying to reach does not support HTTPS requests.”

Here’s a link to the Countries app that originally came from the YouTube tutorial. I’ve detatched the bulk of the code on the second screen, added a “debug” label, and written the API responses to that label so you can see the error. [https://x.thunkable.com/copy/3cac341ddea2ac628d6d0c037fce60d3](https://x.thunkable.com/copy/3cac341ddea2ac628d6d0c037fce60d3).

I have students trying to build this app, and they’re having trouble. This app used to work fine for me, so I’m wondering if something changed recently with Thunkable. Note that I can’t get the Thunkable weather app to work anymore either - same results as the Countries 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: [March 15, 2021, 8:42pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/3 "2021-03-15T20:42:45Z")

</div>

@ronturcotte Your project works correctly in the Thunkable Live app on an iPhone. So I think the issue is trying to access the API through a published Web App, correct?

---

<div class="post-metadata">

### Author: ![ronturcotte](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@ronturcotte](https://community.thunkable.com/u/ronturcotte)
#### Post date: [March 15, 2021, 11:32pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/4 "2021-03-15T23:32:58Z")

</div>

I haven’t tried it in IOS, but it doesn’t work in the live app on Android, nor using web preview.

---

<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: [March 16, 2021, 1:04am UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/5 "2021-03-16T01:04:36Z")

</div>

You’re right. I get “Network request failed” when I preview this in Thunkable Live on an Android phone.

---

<div class="post-metadata">

### Author: ![ronturcotte](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@ronturcotte](https://community.thunkable.com/u/ronturcotte)
#### Post date: [March 18, 2021, 11:24am UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/6 "2021-03-18T11:24:45Z")

</div>

Any updates on this issue? It seems like a Thunkable bug, but it would be helpful to have confirmation. Of course, a solution would be helpful too. 🙂

---

<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: [March 18, 2021, 11:40am UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/7 "2021-03-18T11:40:51Z")

</div>

I don’t think it is a Thunkable issue. I believe this is a permission issue. Some API services allows that the request comes from one specific address (origin) and the response is redirected to another address and some do not allow this is it might contribute in security and privacy issues. I think this is what is being experienced by Thunkable as a Web App and that Thunkable internally redirects the response to your app.

This is usually managed by API CORS settings.

**[Additional Info]**  
Check this write up

> **[A Guide to Solving Those Mystifying CORS Issues](https://blog.container-solutions.com/a-guide-to-solving-those-mystifying-cors-issues)**
>
> Cross-Origin Resource Sharing is confusing for a software developer. They are security mechanisms built into all browsers and must be fixed in the system.

---

<div class="post-metadata">

### Author: ![ronturcotte](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@ronturcotte](https://community.thunkable.com/u/ronturcotte)
#### Post date: [March 18, 2021, 12:04pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/8 "2021-03-18T12:04:29Z")

</div>

So, why would it work on IOS and not on Android?

---

<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: [March 18, 2021, 12:06pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/9 "2021-03-18T12:06:42Z")

</div>

It’s a browser specific. Check the article I included in the post.

---

<div class="post-metadata">

### Author: ![ronturcotte](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@ronturcotte](https://community.thunkable.com/u/ronturcotte)
#### Post date: [March 18, 2021, 12:15pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/10 "2021-03-18T12:15:48Z")

</div>

Ah - I understand. Chrome confirms the issue as well - at least when I preview on the browser, I see a CORS error in the console. Now I’m trying to understand what changed - because this app used to work. I tested it on an Android phone before assigning it to students. I also had a working app with openweathermap, and that one doesn’t work anymore either.

Thanks so much for your help.

---

<div class="post-metadata">

### Author: ![jmrchy](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@jmrchy](https://community.thunkable.com/u/jmrchy)
#### Post date: [March 20, 2021, 5:40pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/11 "2021-03-20T17:40:45Z")

</div>

Hey,

A Web\_API call still working 2 or 3 weeks ago doesn’t works any more in the Thunkable Live app on ANDROID 10. Still working with Thunkable Live on ANDROID 9. And OK too with the preview.  
It seems to have a link with the security accès, https OK, http not.

I have an URL that works ok on any browser in both mode http and https :  
[api.ipify.org/?format=json](http://api.ipify.org/?format=json)

Anybody can test with the followig link that the http access doesn’t work with live ANDROID 10.  
[https://x.thunkable.com/copy/c0d7cf3257a8dc86b24b3d4bfa51f741](https://x.thunkable.com/copy/c0d7cf3257a8dc86b24b3d4bfa51f741)

Bug or not ?  
Thanks

---

<div class="post-metadata">

### Author: ![jmrchy](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@jmrchy](https://community.thunkable.com/u/jmrchy)
#### Post date: [March 26, 2021, 11:50am UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/12 "2021-03-26T11:50:36Z")

</div>

Hey,  
Thanks a lot, corrected with update version 264.

Regards,. JM Rouchy

---

<div class="post-metadata">

### Author: ![ronturcotte](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@ronturcotte](https://community.thunkable.com/u/ronturcotte)
#### Post date: [March 30, 2021, 1:22am UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/13 "2021-03-30T01:22:17Z")

</div>

My API problem appears to have been resolved with 264 as well.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:26pm UTC](https://community.thunkable.com/t/solved-connecting-to-an-api/1197557/14 "2024-11-08T13:26:01Z")

</div>


