4

In my instance of Marketing Cloud, our contact Key is a Person Contact ID from our Salesforce Service Cloud org. These values are 18 characters. When a person uses their mobile device to opt-in to SMS, a contact is created with their mobile phone number as the contact key (since their phone doesn't know their Person Contact ID). I am creating a process to fix these contacts, but I first need a way to get all the contacts with bad contact keys.

I am trying to use the /contacts/v1/attributes/search REST API, but there seems to be very poor documentation about the ConditionSet. Simply, I want to get all contacts where Contact.Contact Key Equals MobileConnect Demographics.Mobile Number.

{
    "request": {
        "attributes": [
            {
                "key": "MobileConnect Demographics.Mobile Number"
            },
            {
                "key": "Contact.Contact ID"
            },
            {
                "key": "Contact.Contact Key"
            }
            ]

    },
    "conditionSet": {
        "operator": "And",
        "conditionSets": [],
        "conditions": [{
            "attribute": {
                "key": "Contact.Contact Key"
            },
            "operator": "Equals",
            "value": {
                "items": ["MobileConnect Demographics.Mobile Number"],
                "isAttribute": true
            }
        }]
    }
}

Unfortunately, I get the following error when I try this:

{
    "page": 0,
    "pageSize": 0,
    "count": 0,
    "links": {},
    "requestServiceMessageID": "743ff7a8-874e-47ac-9be3-de924cf4a323",
    "resultMessages": [
        {
            "resultType": "Validation",
            "resultClass": "Error",
            "resultCode": "InvalidAttribute",
            "message": "Data Type 'Phone' for Referenced Attribute 'Mobile Number' in Value for Attribute 'Contact Key' must be Text."
        },
        {
            "resultType": "Validation",
            "resultClass": "Error",
            "resultCode": "ValueNotAllowed",
            "message": "Value 'null' used for Attribute with DefinitionID 'd94f7d4d-dbe3-e611-9fee-00110a67f371' is not valid for Data Type 'Text' and Operator 'Equal'."
        }
    ],
    "serviceMessageID": "16c874c4-f5f6-45b1-b990-47bf1bcf4d82"
}

Any ideas or thoughts on how to solve this? I've tried a number of alternates and none seem to work.

  • You can't update contact keys. This is going to be very troublesome for your use case – Samuel Dare Aug 4 '17 at 15:04
  • You would have to delete it and possibly republish it – Samuel Dare Aug 4 '17 at 15:06
  • Frustrating that there's no additional documentation on ConditionSet. – Adam Spriggs Aug 4 '17 at 17:18
3

If you do a GET on /contacts/v1/rest you can get a list of all of the methods. One of which is dataTypes, so if you do a GET on /contacts/v1/dataTypes, you'll have a list of available operators.

So if you can assume that Contact Keys that are phone numbers start with 1, you can use this POST to /contacts/v1/attributes/search:

{
    "request": {
        "attributes": [
            {
                "key": "MobileConnect Demographics.Mobile Number"
            },
            {
                "key": "Contact.Contact ID"
            },
            {
                "key": "Contact.Contact Key"
            }
            ]

    },
    "conditionSet": {
        "operator": "And",
        "conditionSets": [],
        "conditions": [{
            "attribute": {
                "key": "Contact.Contact Key"
            },
            "operator": "Begins",
            "value": {
                "items": ["1"]
            }
        },
        {
            "attribute": {
                "key": "MobileConnect Demographics.Mobile Number"
            },
            "operator": "IsNotNull",
            "value": {}
        }]
    }
}

I found the /contacts/v1/rest example in the SFMC Postman collection on Github.

  • Thanks for the Github link @Adam - you just made my day. – Christopher Carswell Jul 10 '18 at 22:58
0

I am experiencing the another issue with this request.

when I am sending the request to access the record I am getting below error.

{ "resultType": "Validation", "resultClass": "Error", "resultCode": "InvalidAttribute", "message": "There is no Attribute with FullyQualifiedName 'Dataextensionname.SubscriberKey'." }

I have the same name of the Attribute in my DE.then why I am getting this error?

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.