Bubble / Dropsource - Postman API Call


#1

Hello, I believe this one is over my pay grade.

This API call

https:// appname .io/api/1.1/obj/user_categories?constraints=%5B%7B%22constraint_type%22:%22contains%22,%22value%22:%22oDEaaG%22,%22key%22:%22user_id_list%22%7D%5D

is throwing the following error:

{
“statusCode”: 400,
“body”: {
“status”: “MISSING_DATA”,
“message”: “Invalid data for endpoint user_categories, key user_id_list: object with this id does not exist: oDEaaG”
},
“args”: {
“bubble_code”: “1542606583546x713398824911564500”
}
}

The same call works if I change the constraint type to “equals” and the “key” to a field name that is not a list. I have confirmed that the data is present and I can retrieve it through the bubble platform, but this call is being used by Dropsource to link my bubble backend.

Anybody have any thoughts on this?


#2

Does it work in postman?


#3

No, the call is not working in Postman and I’m not sure why. If I change the constraint to equals and search a field that is not a list then the call is successful.


#4

NB: EDITED

When i url decoded your api call i get this.

https://appname.io/api/1.1/obj/user_categories?constraints= [{"constraint_type":"contains","value":"oDEaaG","key":"user_id_list"}]

So from this call you’re implying that you have a table called user_categories and this table has a field called user_id_list which is a list of texts (will come back to this).
And your query is asking if this user_id_list contains the text value oDEaaG

And your error message says:
Invalid data for endpoint user_categories, key user_id_list: object with this id does not exist: oDEaaG

One thing i see from this error message is the word object . This makes me suspect that your user_id_list is not a list of texts but rather a list of another type, maybe User.
While bubble represent an object from another table with its id, a text, remember that it is not really a text but an object.
So in your case, the list of ids (texts) you see are actually a list of objects.

Now i’m not 100% sure on this but i think what bubble is doing is searching the linked table (e.g. User) to first find that object with that id.
If it finds it then search the fields to see if any of the fields list contains the id.
But if it doen’t find any object with that id, that is when it throws that 400 response with the error that there is no object that id.

So in your case it means there is no User with an id of oDEaaG.

I know you will be thinking, if there is no User with that id why shouldn’t the api call just return 200 with an empty result.
This is because i think bubble first search if there is an object with that id before it even does the searching in your constraint.

So how do you avoid this issue? There are several ways.

One, you can first make sure that the there exists an object with that id you’re going to use in your search. It doesn’t necessarily have to be referenced in your search field. But it must exist in it own table.

Alternatively you can create a new field on the user_categories table which is of type list of texts. Then whenever you save the user list in the user_id_list in the user_categories table, you save the ids (which are texts) in this new field.
Since this new field is a list of texts even if the id you provide doesn’t exist bubble will not throw any error and rather return 200 with an empty list.


#5

Thanks @seanhoots! So, I created a new field that contained a List of Users (Texts). The API call is now able to find the user. Thanks again!


#6

Excellent breakdown!