How to use $in in request

I have to pull /Accounts against specific IDs and trying different methods but not working.

e.g 

rest/v11_8/Accounts?filter[0][id][$in]=[ae6b1eba-eff3-11eb-b5b6-068d8b4b7195]

  • the correct syntax should be something like this: ( I haven't tested it 

    https://<instance>/rest/v11_13/Accounts?filter[0][id][$in][]=21a74144-9e8a-11eb-b1e9-067f2945c900&filter[0][id][$in][]=22b14daa-9e8a-11eb-80ac-067f2945c900

  • I actually converted filter JSON object and converted in query string online here [ https://www.convertonline.io/convert/json-to-query-string ] and it worked

  • I would recommend to use the POST filter api, especially if you are passing a number of filters/conditions (like a $in calls for).

    Reason being that urls have a much shorter accepted limit than post payloads.

    Example:

    POST /rest/v10/Leads/filter

    {
        "fields": "id,date_modified,first_name,last_name",
        "filter": [
            {
                "$and": [
                    {
                        "date_modified": {
                            "$gte": "2021-10-17T23:12:15+00:00"
                        }
                    },
                    {
                        "date_modified": {
                            "$lt": "2021-10-23T01:04:43+00:00"
                        }
                    },
                    {
                        "id": {
                            "$in": [
                                "0719c890-2fa0-11ec-8dd2-0221da82edeb",
                                "0711ba6a-2fa0-11ec-8b02-0221da82edeb",
                                "07091018-2fa0-11ec-ac61-0221da82edeb",
                                "06ffe3a8-2fa0-11ec-a2f1-0221da82edeb",
                                "06f6e65e-2fa0-11ec-8c2e-0221da82edeb",
                                "06ee9922-2fa0-11ec-a3bc-0221da82edeb",
                                "06e6ad48-2fa0-11ec-bda2-0221da82edeb"
                            ]
                        }
                    }
                ]
            }
        ],
        "max_num": 10,
        "offset": 0,
        "order_by": "date_modified:DESC,id:DESC"
    }

    Hope it helps!

    --

    Enrico Simonetti

    Senior Manager, Integrations Development

    SugarCRM Inc