API Call -- Postman testing error

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 am able to retrieve the information inside of bubble in a repeating group, but this call is being used by Dropsource to link my bubble backend.

Anybody have any thoughts on this?

To work this out, you’d need to check the data in Bubble, and if it definitely does exist, check the privacy rules for that field vs the authentication if any.

Hey @davidtgilpin

I don’t think you can do a nested search on a list like that. You’ll have to search the user_id_list thing first, and then pass the _id value into a second search.

For example a thing of random’s with a list of junk’s within it.

First search junk:

Second search random with _id from junk:

The desire (I would assume) would then be to pass an array of _id’s to the second search, but I don’t believe the Data API currently supports that. Maybe somebody above BOTH our pay grades can help with that part. :slight_smile:

1 Like

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.

Let me use this table @mebeingken post above to exemplify what i think is happening.
From random table above we see there are two list fields.
The text_list is a list of texts while the Junk field is a list of Junks ( note that Junk is another Thing/table)

If you were to make an api call with a list contains constraint using the text_list field, even if you use a value say “hello” which is not in the list, you will not get any error and the api call will return a 200 response.

But assuming you were to use the Junk field in your constraint and use a value say “123” and there is no row in the Junk table with id “123” the api call will fail and return a 400 response.

But again assuming there was a row with id “100” in the Junk table, then even though in the random table above, the junk field list doesn’t contain “100” the api call will still be successful and return a 200 response. This is because there exists an object (Junk) with id “100” (even if our search field doesn’t contain this value).

Hope this makes sense and i’m not spewing gabbage. lol

Thank you for the detailed response! You were right. When I change the search to look for a list of users (text list only) the call works perfectly. Obviously, there needs to be a way to do a nested search. For now, I will adjust my data so the list of users (users) and list of users (texts) contain the same information to cover this search.

Thanks again!