Legacy Dev Forum Posts

 View Only

Sign Up

Extract values from User Search

  • 1.  Extract values from User Search

    Posted 06-05-2025 18:08

    Komali_Sidagam | 2021-02-10 15:18:05 UTC | #1

    Hi,

    I built a query in Python and want to extract few values like, user id, division id, and name from the User search Response, but when m trying to use loads/dumps/or trying to iterate, it is throwing me below errors. could someone please help me in retrieving required values like ids/names from below response.

    AttributeError: 'UsersSearchResponse' object cannot iterate AttributeError: 'UsersSearchResponse' object has no attribute json Object of type UsersSearchResponse is not JSON serializable

    My output for user search is as below: {'currentpage': '/api/v2/users/search?q64=H4sIAAAAAAAAAD3NMQ-CMBCG4f9yM4srG8ESXGrUOhhjyCknElpar9EEP67BRPX9558N8EwOvKQXiF4Yg-3BN6BeIxlWm-QQr6XKtvJEyTwbEnXK-R0KIqMOCOmtQt5FYR4yD5dgyuYU5GocNyWDuFOMmAaYhcF8p5rQ1suUJ-THS2eHs7ieKlUKWRVCJWXMH8BpJS0Y6wAAAA%3D', 'nextpage': None, 'pagecount': 1, 'pagenumber': 1, 'pagesize': 25, 'previouspage': None, 'results': [{'acdautoanswer': False, 'addresses': [{'address': 'xyz@e.cmail.com', 'countrycode': None, 'display': None, 'extension': None, 'mediatype': 'EMAIL', 'type': 'WORK'}], 'authorization': None, 'biography': None, 'certifications': None, 'chat': {'jabberid': '5fa5a0bb550ee31962ee4a89@xyz.orgspan.com'}, 'conversationsummary': None, 'department': ' IT Teams', 'division': {'id': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'name': '', 'selfuri': '/api/v2/authorization/divisions/{divisionID'}, 'email': 'xyz@email.com', 'employerinfo': None, 'geolocation': None, 'groups': None, 'id': 'XXXXXXXXXXXXXXXXXX', 'images': None, 'languagepreference': None, 'languages': None, 'lasttoken_issued': None, 'locations': None, 'total': 1, 'types': ['users']}


    Jerome.Saint-Marc | 2021-02-10 16:06:24 UTC | #2

    Hello,

    Not that I know much about python. But you are probably not iterating on the right attribute. getuserssearch returns a UsersSearchResponse. The list of users is in the *results* attribute. I mean if you have: apiresponse = apiinstance.getuserssearch Then the list[User] is in api_response.results

    Regards,


    Komali_Sidagam | 2021-02-12 07:18:52 UTC | #3

    Got it Marc. It helped. Thank you !


    system | 2021-03-15 07:18:53 UTC | #4

    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: 9955