Calling API from external source

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:

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?

1 Like

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.

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

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

Can you post the code snippet of your html request?

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


import json
import requests
import pandas as pd

shops_endpoint = “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)


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

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

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

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