Hey @davidtgilpin just realized you asked this question here as well as in the dropsource forum.
I answered you there but since this is more of a bubble question than a dropsource one i’m reposting my response from dropsource here just in case someone also runs into this issue.
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 list contains
constraint-type 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.