REST API filter for list of IDs

( SuiteCRM Version 7.11.20 JSON API v8)
Hi
Iā€™m using the suitecrm Json REST API to access data and iā€™m trying to compose a query that results with all records that fit to a list of IDs.
According to the documentation here: JSON API :: SuiteCRM Documentation
Iā€™ve composed the below request:
GET https://domainname.com/Api/V8/module/tablename?filter[operator]=or&filter[id][eq]=c46ff350-c3e6-d263-ca3e-613dd3f6cddc&filter[id][eq]=7fdfd47f-f2a7-442b-411b-613dd45edbe8
This returns all the records in the table.

Tried changing the filter operation to ā€˜andā€™ : returned only the record of the last id: 7fdfd47f-f2a7-442b-411b-613dd45edbe8 < this seems like a reasonable behavior.

So, is this doable without me quering for every record separately ?

Also tried this kind of API that didnā€™t work:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.0/Integration/Web_Services/REST_API/Endpoints/modulefilter_GET/
not sure if its supported in suiteCRM though

Thanks in advance!
Y

Hey there,

Have you found a solution for this?


This issue rings a bell, I believe Iā€™ve found issues previously with the APIā€™s OR operator

Iā€™ve had a look around and found this old thread:

It seems that this is a known issue with the API, raised as a Bug here:

With a proposed solution here:

Note that this change would be non-upgrade safe, as it is not merged into the main product


Does the above change help in resolving your API issues?

Thanks for your reply John!

Iā€™ve checked out the code that @serfreeman1337 wrote, only this commit:

Tried running the below query returned only single record (valid for the last id) in the result set:
Api/V8/module/Contacts?filter[operator]=or&filter[id][eq]=7db9eae4-a8c1-b73c-45ad-6158a2dd3d95&filter[id][eq]=cd833f5c-5837-0244-1484-6158a60df4c4

The above two ids are valid records so with this query I expected to get both.

Note iā€™m not a php dev (only java / c# dev).
Iā€™ve manually merged the changes to Filter.php to overwrite my version of the file.
restarted the webserver (apache)
Than I ran Admin portal > Repair > Quick Repair and Rebuild
Hope its the right way to rebuildā€¦

Again, Thanks

This quick fix should allow array values for requests:

example request:
Api/V8/module/Contacts?filter[operator]=or&filter[id][eq][]=7db9eae4-a8c1-b73c-45ad-6158a2dd3d95&filter[id][eq][]=cd833f5c-5837-0244-1484-6158a60df4c4

note the []

1 Like