# Calling API from external source

**URL:** https://forum.adalo.com/t/calling-api-from-external-source/6275
**Category:** Get Help
**Created:** [November 23, 2020, 5:33pm UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275 "2020-11-23T17:33:16Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![iron49man](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/iron49man/32/2474_2.png) [@iron49man](https://forum.adalo.com/u/iron49man)
#### Post date: [November 23, 2020, 5:33pm UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/1 "2020-11-23T17:33:16Z")

</div>

Hello, I’m trying to call my app’s API from a completely different application but I keep getting a 401 Unauthorized error. This is the code I’m using:

`$.ajax({`  
`method:'GET',`  
`url:'https://api.adalo.com/apps/[myApp'sCollectionID]',`  
`'Authorization': 'Bearer [my API key]',`  
`'Content-Type': 'application/json',`  
`success:function(response){`  
`myArray = response.data`  
`buildTable(myArray)`  
`console.log(myArray)`  
`}`  
`})`

I know it’s a 401 error because it shows in the console:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/f/fbfd52df9e0c39ed7dff5f8428b3f715ce6d1f64.png)

I have a feeling it’s because I’m not adding the headers properly but I’ve tried adding the headers in 100x different ways and still can’t get it to work. Anyone know the proper syntax here?

---

<div class="post-metadata">

### Author: ![harrymryder](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@harrymryder](https://forum.adalo.com/u/harrymryder)
#### Post date: [November 24, 2020, 5:04pm UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/2 "2020-11-24T17:04:15Z")

</div>

I think there might be an issue on Adalo’s side.

I’ve been calling the API successfully for the past month but in the last couple of days it’s stopped working.

---

<div class="post-metadata">

### Author: ![iron49man](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/iron49man/32/2474_2.png) [@iron49man](https://forum.adalo.com/u/iron49man)
#### Post date: [November 24, 2020, 10:16pm UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/3 "2020-11-24T22:16:54Z")

</div>

Are you also getting a 401 Unauthorized error or something else?

---

<div class="post-metadata">

### Author: ![harrymryder](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@harrymryder](https://forum.adalo.com/u/harrymryder)
#### Post date: [November 25, 2020, 7:27am UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/4 "2020-11-25T07:27:31Z")

</div>

Nope, getting a JSON loading error:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Which suggests the JSON response I’m receiving from Adalo isn’t valid

---

<div class="post-metadata">

### Author: ![iron49man](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/iron49man/32/2474_2.png) [@iron49man](https://forum.adalo.com/u/iron49man)
#### Post date: [November 25, 2020, 3:22pm UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/5 "2020-11-25T15:22:30Z")

</div>

Can you post the code snippet of your html request?

---

<div class="post-metadata">

### Author: ![harrymryder](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@harrymryder](https://forum.adalo.com/u/harrymryder)
#### Post date: [November 25, 2020, 4:11pm UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/6 "2020-11-25T16:11:40Z")

</div>

Sure, here you go, but I’m using python

* * *

import json  
import requests  
import pandas as pd

shops\_endpoint = “[https://api.adalo.com/apps/](https://api.adalo.com/apps/)[App ID]/collections/[Collection ID]”  
shops\_headers = {“Authorization”: “Bearer [API Key]”, “Content-Type”: “application/json”}

shops\_response = requests.get(shops\_endpoint, headers=shops\_headers)  
shops\_list = shops\_response.json()

shops = pd.DataFrame(shops\_list)

* * *

---

<div class="post-metadata">

### Author: ![anon78309838](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@anon78309838](https://forum.adalo.com/u/anon78309838)
#### Post date: [November 26, 2020, 11:02am UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/7 "2020-11-26T11:02:12Z")

</div>

Are these issues persistent or intermittent? I just did various tests and all requests were made succesfully.

---

<div class="post-metadata">

### Author: ![iron49man](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/iron49man/32/2474_2.png) [@iron49man](https://forum.adalo.com/u/iron49man)
#### Post date: [November 26, 2020, 3:53pm UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/8 "2020-11-26T15:53:52Z")

</div>

Persistent. I am trying to call it with a script in an HTML block. I finally formatted it correctly because I got around the 401 Unauthorized error but now I’m getting this error.

![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/c/c25aa0f7d6494302ee085ce546f13d37d91dcb93.png)

Also worth noting I am using Brave Browser but shields are down.

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/system/32/40401_2.png) [@system](https://forum.adalo.com/u/system)
#### Post date: [December 6, 2020, 3:54pm UTC](https://forum.adalo.com/t/calling-api-from-external-source/6275/9 "2020-12-06T15:54:04Z")

</div>

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