# Web API not work

**URL:** <https://community.thunkable.com/t/web-api-not-work/2530550>\
**Category:** Questions about Thunkable X\
**Created:** [August 3, 2023, 3:08pm UTC](https://community.thunkable.com/t/web-api-not-work/2530550 "2023-08-03T15:08:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [August 3, 2023, 3:08pm UTC](https://community.thunkable.com/t/web-api-not-work/2530550/1 "2023-08-03T15:08:00Z")

</div>

Hi Guy,

I try to learn API in thunkable and sample api is book. i am not sure why is not return anything.

Here the url and my block.  
url : [https://api.alquran.cloud/v1/ayah/262](https://api.alquran.cloud/v1/ayah/262)

block  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/3/a3123f3418d7a8bf7192e3a79e9eeef3ce6658e2.png)

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [August 3, 2023, 5:48pm UTC](https://community.thunkable.com/t/web-api-not-work/2530550/2 "2023-08-03T17:48:29Z")

</div>

you have to drill downa few more levels:  
see the additional (nested) blocks i’ve used:

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

here is my output

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

you could also use this notation (my preferred):

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

note that you don’t have to nest blocks - one level is needed but the full “path” in the the json tree needs to be provided - concatenated by dot. if an array is involved,it could be coded, for example` data.book[1].number`

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [August 3, 2023, 11:14pm UTC](https://community.thunkable.com/t/web-api-not-work/2530550/3 "2023-08-03T23:14:29Z")

</div>

Hi @manyone

thank you for your guidance. so most important i have to understand how the json is formatted right? i try to use json formatter and it make sense.

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

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [August 4, 2023, 3:16pm UTC](https://community.thunkable.com/t/web-api-not-work/2530550/4 "2023-08-04T15:16:21Z")

</div>

Hi @manyone

if i want to get following text does not seem work. if you can advice me how the block look like.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/2/02317b93761f7a22b53bd8782b5501c128ba70b5.png)

my block

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/1/718539e42af85565b4ebe1cc73d6c2fac0c40aea.png)

url :[http://api.alquran.cloud/v1/surah/114](http://api.alquran.cloud/v1/surah/114)

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [August 4, 2023, 7:45pm UTC](https://community.thunkable.com/t/web-api-not-work/2530550/5 "2023-08-04T19:45:22Z")

</div>

instead of get property “ayahs”, you should try get\_property “ayahs[1]” (because ayahs is an array (you can tell because it starts with “[”

i f you want to handle arrays dynamically so you don’t have to pre-count how many elements in an array,  
use the method used here:

> [@\[SOLVED\] Trying to parse a list of results in web api](https://community.thunkable.com/t/solved-trying-to-parse-a-list-of-results-in-web-api/2530450/2):
>
> use this scheme:

study the way the ‘for each item’ block is used to loop thru the array. you will have to do a similar thing.

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [August 6, 2023, 5:10am UTC](https://community.thunkable.com/t/web-api-not-work/2530550/6 "2023-08-06T05:10:48Z")

</div>

I try to simulate same block but not work.

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

web api url: [http://api.alquran.cloud/v1/surah/114](http://api.alquran.cloud/v1/surah/114)

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [August 6, 2023, 8:19am UTC](https://community.thunkable.com/t/web-api-not-work/2530550/7 "2023-08-06T08:19:49Z")

</div>

> [@ozel1978](#):
>
> [http://api.alquran.cloud/v1/surah/114](http://api.alquran.cloud/v1/surah/114)

note the level of nesting for ayah

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/1/01254305412974b91089040a92401a6545c600ff.png)

here’s the result

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

here’s another way of handing the json structure by using a count block - note how blocks nest

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

this time, using a short cut notation

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

finally, here is the first version (at the top) expressed in short cut notation (note “data.ayahs”, compare to the first version)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/4/54b7ca40dd3193fe3763e2693965d0b422b71adb.png)

all of these produce the same output

here’s the link to the toy project (refer to screen 3)  
[https://x.thunkable.com/copy/93ec9cf50be75dcefd5986ab596bf439](https://x.thunkable.com/copy/93ec9cf50be75dcefd5986ab596bf439)

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [August 6, 2023, 2:44pm UTC](https://community.thunkable.com/t/web-api-not-work/2530550/8 "2023-08-06T14:44:22Z")

</div>

It worked for me. thank you for your help.

I have curiosity about your method, why not using url instead of using json format in the block?

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [August 7, 2023, 2:15am UTC](https://community.thunkable.com/t/web-api-not-work/2530550/9 "2023-08-07T02:15:27Z")

</div>

it’s just a debugging technique.

i knew i was going to do a lot of trial and error so i copied the results of the first call and saved it - and used it every time i tested my changes.

if i had used the api call in my block - i would have been calling the api every single time and most likely it woud have returned the same value. also if the api call had a price - i would be charged for every call.

it’s just a way of saving time. after i’m done i could restore the “get data” portion back to the usual get-api call.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [November 5, 2023, 2:15am UTC](https://community.thunkable.com/t/web-api-not-work/2530550/10 "2023-11-05T02:15:40Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
