Legacy Dev Forum Posts

 View Only

Sign Up

Unable to get ids from externalcontacts API in Python or convert to json

  • 1.  Unable to get ids from externalcontacts API in Python or convert to json

    Posted 06-05-2025 18:09

    jtran7 | 2024-07-09 13:20:45 UTC | #1

    Been using this api to get all the external ids in the org but I been having trouble trying to select all of them. /api/v2/externalcontacts/contacts

    However, I been unable to convert it successfully to a json object or grab all the ids I need. I can access all the way to entities but it won't let me convert to json and when I sort them I can't get the 'id' key needed. Any recommendation on how to grab all the external contact ids from the results?

    Api_resonse is the object/list returned from the api for python.

    api_response.entities

    I'm trying to get the ids for the contacts but it doesn't let me go further then entities in the object returned.

    [{'address': None, 'canonicalcontact': None, 'cellphone': {'acceptssms': False, 'countrycode': None, 'display': '+XXXXXXXXXX', 'e164': None, 'extension': None, 'userinput': '+XXXXXXXXX'}, 'createdate': datetime.datetime(2023, 8, 30, 18, 45, 1, tzinfo=tzutc()), 'customfields': None, 'externaldatasources': None, 'externalorganization': None, 'externalsystemurl': None,

    }

    'externaldatasources': None, 'externalorganization': None, 'externalsystemurl': None, 'facebookid': None, 'firstname': 'XXXX', 'homephone': None, 'id': 'XXXXXXX', 'lastname': 'XXXXX', 'lineid': None, 'mergeoperation': None, 'mergeset': None, 'middlename': None, 'modifydate': datetime.datetime(2021, 8, 16, 18, 35, 2, tzinfo=tzutc()), 'otheremail': None, 'otherphone': None, 'personalemail': None, 'salutation': None, 'schema': None, 'selfuri': '/api/v2/externalcontacts/contacts/XXXXXXXXXXXX, 'surveyoptout': None, 'title': None, 'twitterid': None, 'type': 'Curated', 'whatsappid': None, 'workemail': None, 'work_phone': None},


    Jerome.Saint-Marc | 2024-07-10 14:12:41 UTC | #2

    Hello,

    entities is Python list.

    You can loop through the elements with something like this:

    for excontact in api_response.entities:
      print(excontact.id)

    Regards,


    system | 2024-08-10 14:13:37 UTC | #3

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