0

I'm using the createContacts REST API method to create a new Contact and I'm including the MobileConnect Demographics Attribute Set in the same request, which adds the Contact in MobileConnect. We can also use the updateContacts method to update a Contact. This works fine — refer to screenshot below from the All Contacts page in Contact Builder.

However I can't find a way to retrieve a mobile number for an existing Contact using the SOAP or REST API. Does anyone know how to do this?

All Contacts

2 Answers 2

1

I've figured out that you can do this using the attributes/search route in th REST API.

Using this method, you can retrieve any Attribute from any Attribute Set in your Contact Model. Very handy.

In the example below, I'm retrieving the Email Address from all Subscribers and the Mobile Number from the MobileConnect list. Note that Contacts is the Data Extension name used in my Population and Contact Key is the field value in that Data Extension (linked to the Contact Record).

You also can include other key name/value pairs in the attributes array to retrieve field values from other Data Extensions used in your Contact Model.

POST https://www.exacttargetapis.com/contacts/v1/attributes/search
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
    "request": {
        "attributes": [{
                "key": "Email Addresses.Email Address"
            },
            {
                "key": "MobileConnect Demographics.Mobile Number"
            }]

    },
    "conditionSet": {
        "operator": "And",
        "conditionSets": [],
        "conditions": [{
            "attribute": {
                "key": "Contacts.Contact Key"
            },
            "operator": "Equals",
            "value": {
                "items": ["643268b7-0d37-9aff-3685-1eb068d21b5e"]
            }
        }]
    }
}
0

I was able to retrieve the mobile number for all contacts using REST API, or for a given contact using AMPScript or Server Side Javascript.

For all contacts, you can use:

GET: https://www.exacttargetapis.com/contacts/v1/attributeSets/name:MobileConnect%20Demographics?$page=<pageNo>

To retrieve a single contact mobile i use this (being contactID the one of the contact you want the mobile):

var mobileConnectDE = DataExtension.Init("DATA_EXTENSION_EXTERNAL_KEY");
var rowMobileConnect = {};
try {        
  rowMobileConnect = mobileConnectDE.Rows.Lookup(['_ContactID'], [***contactID***]);      
  Write("Retrieve status: " + Stringify(rowMobileConnect));

  for(var i in rowMobileConnect){      
     Write("MobileNumber: " + rowMobileConnect[i]['_MobileNumber']);
  }   
} catch (ex) { 
  Write("An error has occurred retrieving rows: " + Stringify(ex));  
  return; 
}

You can put this piece of code in a landing page.

2
  • Let me know if it works for you
    – SebOB
    Commented Sep 16, 2016 at 8:26
  • The endpoint you provided will return all mobile contacts and does not appear to let you filter for individual contacts using URL parameters. However, I've found a solution, which I will post as a separate answer. Commented Sep 19, 2016 at 3:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .