Legacy Dev Forum Posts

 View Only

Sign Up

How to update the primary contact info

  • 1.  How to update the primary contact info

    Posted 06-05-2025 18:24

    Erik_Hanssens | 2022-11-23 13:52:04 UTC | #1

    Hi,

    We are trying to update the primary contact information (the primary work phone number) by using API's. I didn't found enough details on the developer tools. I am trying a PATCH request to /api/v2/users/{userId}

    From the API Explorer documentation site, I see that type is defined as (string) Valid values: PRIMARY, WORK, WORK2, WORK3, WORK4, HOME, MOBILE, MAIN, OTHER.

    But when sending the following addresses, I got an error 400 ("message": "Input is invalid or malformed. Reason: Invalid address type: primary")

    "addresses": [
            {
                "address": "+3221234567",
                "display": "+32 2 123 45 67",
                "mediaType": "PHONE",
                "type": "PRIMARY",
                "countryCode": "BE"
            },
            {
                "address": "+32412345678",
                "display": "+32 412 34 56 78",
                "mediaType": "PHONE",
                "type": "MOBILE",
                "countryCode": "BE"
            }
        ]

    Replacing PRIMARY by WORK is accepted but does not do the job.

    Can you please tell me how to define the primary address?

    Thanks in advance,

    Erik


    Jerome.Saint-Marc | 2022-11-24 08:25:05 UTC | #2

    Hello,

    In your PATCH /api/v2/users/{userId}, set version, addresses AND primaryContactInfo attributes. The PRIMARY status is not set in the addresses but in primaryContactInfo.

    Found this old post and did a quick test.

    When using PATCH, setting the PRIMARY email in primaryContactInfo does not seem to be mandatory if you want to update primary voice number. But personally, I prefer to send everything (what I receive from the GET /api/v2/users/{userId}).

    In your case, that should be something like:

    { "primaryContactInfo": [ { "address": "youruseremail_address", "mediaType": "EMAIL", "type": "PRIMARY" }, { "address": "+3221234567", "display": "+32 2 123 45 67", "mediaType": "PHONE", "type": "PRIMARY" } ], "addresses": [ { "address": "+3221234567", "display": "+32 2 123 45 67", "mediaType": "PHONE", "type": "WORK", "countryCode": "BE" }, { "address": "+32412345678", "display": "+32 412 34 56 78", "mediaType": "PHONE", "type": "MOBILE", "countryCode": "BE" } ], "version": 28 }

    Regards,


    Erik_Hanssens | 2022-11-24 13:30:17 UTC | #3

    Hello Jérôme,

    Thanks for your message. The request with primaryContactInfo is accepted but the content is not taken into account. As workaround, I can send a first call with only the primary contact number and a second with all the numbers. This is the only way I found to change an existing primary contact info.

    With kind regards,

    Erik


    Jerome.Saint-Marc | 2022-11-24 14:00:10 UTC | #4

    Can you explain/show what are the primaryContactInfo and addresses you have before doing the update? And values you want after update?

    As I said in my post, you have to send both primaryContactInfo AND addresses in your PATCH.

    I tried to set the primary number and a second one in a single PATCH and it worked.

    So knowing what you have before - and what you are trying to have after the PATCH - would help me try it (if the scenario is different than mines).

    Regards,


    Erik_Hanssens | 2022-11-24 14:41:02 UTC | #5

    I have a user with two phone numbers, a land line and mobile. Initially the mobile phone number is set as primary. I would like to set the land line as primary.

    The initial primaryContactInfo and addresses are

      "primaryContactInfo": [
        {
          "address": "labo_agent5@global.ntt",
          "mediaType": "EMAIL",
          "type": "PRIMARY"
        },
        {
          "address": "+32470123456",
          "display": "+32 470 12 34 56",
          "mediaType": "PHONE",
          "type": "PRIMARY"
        }
      ],
      "addresses": [
        {
          "address": "+3223456789",
          "display": "+32 2 345 67 89",
          "mediaType": "PHONE",
          "type": "WORK",
          "countryCode": "BE"
        },
        {
          "address": "+32470123456",
          "display": "+32 470 12 34 56",
          "mediaType": "PHONE",
          "type": "WORK2",
          "countryCode": "BE"
        }
      ],

    My patch request contains

    {
        "name": "Labo_Agent5",
        "email": "labo_agent5@global.ntt",
        "primaryContactInfo": [
            {
                "address": "labo_agent5@global.ntt",
                "mediaType": "EMAIL",
                "type": "PRIMARY"
            },
            {
                "address": "+3223456789",
                "display": "+32 2 345 67 89",
                "mediaType": "PHONE",
                "type": "PRIMARY"
            }
        ],
        "addresses": [
            {
                "address": "+3223456789",
                "display": "+32 2 345 67 89",
                "mediaType": "PHONE",
                "type": "WORK",
                "countryCode": "BE"
            },
            {
                "address": "+32470123456",
                "display": "+32 470 12 34 56",
                "mediaType": "PHONE",
                "type": "WORK2",
                "countryCode": "BE"
            }
        ],
        "version": 20
    }

    The adresses are the same, the only change is about the primary contact info. The request is accepted but the primary address didn't changed.


    Jerome.Saint-Marc | 2022-11-24 16:58:22 UTC | #6

    You're totally right. My mistake. As a matter of fact, the primaryContactInfo is not taken into account. If you add a number to a user with no existing number assigned, this number will become PRIMARY. When you remove the number which was primary, it in fact automatically switches the remaining number in PRIMARY.

    JSM


    Erik_Hanssens | 2022-11-24 16:32:14 UTC | #7

    Thanks for your help Jérôme, I will open a service request and update this post with the updates. With kind regards, Erik


    system | 2022-12-25 16:32:37 UTC | #8

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