Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Searching for Users

    Posted 06-05-2025 18:18

    andygunther | 2017-05-10 17:39:21 UTC | #1

    I'm using the API to search out a user by email address to see if they exist, before I try to create them - so I can PATCH (Update) them instead of creating if they exist.

    For example, I'm using this body in my POST:

    { "sortOrder": "ASC", "sortBy": "email", "pageSize": 0, "pageNumber": 0, "query": [{ "value": "andyg@the-iec.com", "fields": ["email"], "type": "EXACT", "operator":"AND" }] }

    Then, I get this back, which tells me there was one result. But, I'm not sure how to get the result object, because I need it's ID to perform the update. Can someone point me in the right direction?

    { "total": 1, "pageCount": 2147483647, "pageSize": 0, "pageNumber": 1, "currentPage": "/api/v2/users/search?q64=H4sIAAAAAAAAAD2Oyw6CMBBF2XWaFyzEhHiCqPURGMMqTBCE6A4bU2Q8O-WQlzemXMfA-i-QwX-HYxCUvDwQEnSRyqQwIcgDcGDt0HqLTM42p6jaxAy-3gJrAvnxoaLenJeG0mhLdFX251hSuB-TqXjcVlh8S1dMHJHsalbGezlwAPOl5iKr42YjOLxDTPaYuVhNpQG9LSyMKtxg55RWbt50u0fmWsUOUZHHEwgOMP942W8zlAAAA", "nextPage": "/api/v2/users/search?q64=H4sIAAAAAAAAAD2OwQ6CMAyG36VnNHrlJCKEE0aZicYYMqHCEmBYNhMkvLtjEI9tv_rP4DqW-zAvYPukDp4ONBJUkfKkcAFLHBgbdG6g0zWNqsg6vnM3N4Caxym8aai2pKf3ilJ4Q3eVsVIkrgdk6k7XBZYvElbTi-ADj8mxv3IvAgZYXmIivUWzmIdb1c-qydYBQaWrC_9NCi9w2Rk5ZyeZup0twvqUsCuI0DJgfwfgDTTmchuUAAAA%3D", "types": [ "users" ] }


    tim.smith | 2017-05-10 17:45:12 UTC | #2

    Increase pageSize to greater than zero and set pageNumber to 1.


    andygunther | 2017-05-10 17:46:41 UTC | #3

    Jeez - I knew it would be something stupid... Thx


    andygunther | 2017-05-10 18:24:33 UTC | #4

    So, related, I am getting a 400 back in Developer Tools when I try to perform the PATCH with this body:

    { "name":"Robert Garza", "department":"CAM - Reimbursement", "email":"rgarza@cochlear.com", "addresses":[ { "address":"8261", "mediaType":"PHONE", "type":"WORK"}, { "address":"+13032642161", "mediaType":"PHONE", "type":"WORK2"}], "title":"Recipient Account Collections Specialist", "password":"Welcome1" }

    I tried removing Password, email, and the Address array, and still get the same error.

    Any thoughts? No details in the 400 are coming back.

    Correlation Id is: 2c18c5d4-db90-4fa1-82e7-e530fea7e3c5


    tim.smith | 2017-05-10 18:30:29 UTC | #5

    There's a fix for not getting error messages back that hasn't made it to prod yet. Your issue is that you must include the property version when updating the user. The value should be the value of version when you get the user object. The purpose of this is to ensure that you're updating the version of the object that you think you are.

    For example, if the user's version is 5 and you send 5, but someone else updates the user causing it to bump to 6 before you send your request, your request will fail so you don't accidentally overwrite the other change.


    andygunther | 2017-05-10 18:45:00 UTC | #6

    Gotcha, thanks. I missed that. It is listed as optional in the Dev Tools example.


    system | 2017-06-10 18:54:20 UTC | #7

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 1277