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:
GETFor all contacts, you can use: https://www.exacttargetapis.com/contacts/v1/attributeSets/name:MobileConnect%20Demographics?$page=
- 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");
GET: https://www.exacttargetapis.com/contacts/v1/attributeSets/name:MobileConnect%20Demographics?$page=<pageNo>
var rowMobileConnect = {};
To retrieve a single contact mobile i use this (being contactID the one of the contact you want the mobile):
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;
}
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.