If you would like to update a contact's information, you'll first have to make sure the contact exists. After this, you can either update the user or create a new one. In the example below, we'll update their first name. To do this you'll need to know the user's email.

If you'd like, you can test with our Postman Collection here: Postman collection

Prerequisites

Before you begin, make sure you have valid authorization credentials. Please see this page for more information.

Procedure

In order to search for a contact or update their information, you will need to decide which identifier you'd like to use:

Contact Identifier TypeDefinition
EMAIL

The identifier is an email address.
MOBILE

The identifier is a mobile number.
APP_ALIAS

The identifier is a mobile app alias.
EXTERNAL

The identifier is a value generated by an external system.
IDContact (User) identifier

In our examples, we'll use email. 

  1. Use a POST request to check that the contact exists

    'POST' \  'http://yourdomain.com/api/rest/contact/get' \
    {
      "type": "EMAIL",
      "value": "j.mcexample@example.com"
    }'
    JS
    <soapenv:Envelope
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:ecm="http://yourdomain.com/developer/ecmapi">
        <soapenv:Header/>
        <soapenv:Body>
            <ecm:contactGet>
                <identifier>
                    <type>EMAIL</type>
                    <value>j.mcexample@example.com</value>
                </identifier>
            </ecm:contactGet>
        </soapenv:Body>
    </soapenv:Envelope>
    JS

    Response

    Description

    200From this request, you should receive a 200 response, with information about the contact. This includes information like their contactID.
    400If the profile does not exist you will receive a 400 response. You can also double-check the email used in the call if you believe there is an existing user profile. 

  2. Use a POST request to update the information

    To use contact/update you will need to provide:

      • The contact identifier type in the URL and the body of the call.

      • The attribute to update.

      • The new value.

      • In this example, we update the contact's name. You could substitute in any stored attribute, such as their mobile phone number.

    Please note that the identifier type is written differently in the body of the call and the request URL. In our example, we are using the email address, which is "EMAIL" in the URL, and "emailAddress" in the body of the call. Please see the contact/update entry in Swagger for a full list. 

    POST \'http://yourdomain.com/api/rest/contact/update?identifierType=EMAIL&unifiedIdentifierName=j.mcexample%40example.com' \
    {
    "emailAddress": "j.mcexample@example.com",
    "attributes":
    [
    {"name": "FirstName", "value": "John"},
    {"name": "LastName", "value": "McExample"},
    ]
    }
    JS



    <soapenv:Envelope
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:ecm="http://yourdomain.com/developer/ecmapi">
        <soapenv:Header/>
        <soapenv:Body>
            <ecm:contactUpdate>
                <identifierType>EMAIL</identifierType>
                <contact>                
                    <emailAddress>j.mcexample@example.com</emailAddress>
                    <!--Zero or more repetitions:-->
                    <attributes>
                        <FirstName>John</FirstName>
                        <LastName>McExample</LastName>
                    </attributes>
                </contact>
            </ecm:contactUpdate>
        </soapenv:Body>
    </soapenv:Envelope>
    JS

Conclusion

You should receive a 204 response and no further information. This indicates the profile has been updated. If there was a problem, you might receive a 400 response. 


Related Topics

Engage web service implementation and error handling

Creating a New Contact and Subscribing them to your Newsletter