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

  • thanks for sharing yes it worked (y)

  • 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

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    {
    "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",
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Hope it helps!

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States