Legacy Dev Forum Posts

 View Only

Sign Up

What values are expected in the returnFields array of the /api/v2/users/search

  • 1.  What values are expected in the returnFields array of the /api/v2/users/search

    Posted 06-05-2025 18:01

    agilio | 2017-01-25 00:03:12 UTC | #1

    What or how should returnFields values be formatted to return only id and name?

    { "sortOrder": "ASC", "sortBy": "name", "returnFields": "id" }


    tim.smith | 2017-01-25 16:08:51 UTC | #2

    Per POST /api/v2/users/search, the returnFields property is an array of strings. Try "returnFields": [ "id" ]


    agilio | 2017-01-25 19:37:57 UTC | #3

    Hi Tim,

    I just tested with the below body and it still returned all of the fields. I am correct to assume it should only return ID's correct?

    { "sortOrder": "ASC", "sortBy": "name", "returnFields": [ "id" ] }


    tim.smith | 2017-01-25 20:39:28 UTC | #4

    There's actually an open issue (SRCH-1051) to address this. The issue is that the documentation for the search request is incorrect; the returnFields property isn't supported on this resource. The only search you can use it with is POST /api/v2/search. The typed searches (like /api/v2/users/search) will return the full entities that match the query.

    edit: This body for POST /api/v2/search will yield the results you're looking for:

    {
      "sortOrder": "ASC",
      "sortBy": "name",
      "returnFields": [
        "id",
        "name"
      ],
      "types": [
        "users"
      ]
    }

    Note that in this request, the field name id is actually an alias for guid, which you will see in the response.


    agilio | 2017-01-25 21:41:37 UTC | #5

    Is /api/v2/search exposed in the Developer Tools API explorer?


    agilio | 2017-01-25 21:44:59 UTC | #6

    I found it and that works Thanks! Is there a different place for usage that I should reference to get a better understanding of what key words etc to use?


    tim.smith | 2017-01-26 16:47:38 UTC | #7

    The possible values for returnFields are "self-documenting". Make a request to POST /api/v2/search with the body below to get a full object back. You can use any property name on the entity and can drill down by specifying a field like contactInfo.chat, though you can't drill down into arrays (contactInfo.chat[0]._id isn't valid).

    {
      "types": ["users"],
      "returnFields":["ALL_FIELDS"],
      "pageSize": 1
    }

    edit: SRCH-1121 has been created to add ALL_FIELDS to the documentation for the returnFields property on POST /api/v2/search.


    system | 2017-08-28 19:31:18 UTC | #8


    This post was migrated from the old Developer Forum.

    ref: 835