0

I am trying to use the below api and payload for updating the mobile opt in preference in Salesforce, but I am getting a validation error. Can someone help?

PATCH : https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com/contacts/v1/contacts

payload:

{
   "contactKey":"contackey",
   "attributeSets": [{
         "name":"MobileConnect Subscriptions",
         "items": [{
               "values": [
                     { "name":"Keyword", "value":"Addkeyword" },
                      { "name":"Mobile Number", "value":"mobilenumber"},
                     { "name":"Opt In Status", "value":1},
                     { "name":"Opt Out Status", "value":0}
               ]
         }]
   }]
}

Validation Error:

{
    "operationStatus": "FAIL",
    "rowsAffected": 0,
    "contactTypeID": 0,
    "requestServiceMessageID": "4fe9da2d-1408-45a6-90b8-97a6774ffef6",
    "responseDateTime": "2020-09-09T02:14:42.4487199-06:00",
    "hasErrors": true,
    "resultMessages": [
        {
            "resultType": "Validation",
            "resultClass": "Error",
            "resultCode": "InvalidAttributeSet",
            "message": "The Attribute Set [MobileConnect Subscriptions] has validation errors.",
            "innerResultMessages": [
                {
                    "resultType": "Validation",
                    "resultClass": "Error",
                    "resultCode": "RestrictedValueAttribute",
                    "message": "[DefinitionKey: SubscriptionDefinitionID], [DefinitionName: Keyword], [DefinitionID: b1657179-eeef-e911-b82e-b883035b8991] :: The Attribute has a defined set of allowed values. The current value is invalid. [DefinitionName: Keyword], [DefinitionID: b1657179-eeef-e911-b82e-b883035b8991]",
                    "innerResultMessages": []
                }
            ]
        }
    ],
    "serviceMessageID": "44da64fa-1cb1-4d24-8442-713d72118ed0"
}
2
  • for keyword are you passing a value like 'JOIN' or a GUID value?
    – EazyE
    Sep 9 '20 at 13:51
  • I am passing the add keyword that is configured in my mobile connect Sep 9 '20 at 16:45
2

In the benefit of others, after reaching out to Salesforce, it was understood that the payload needs to be modified in such a way that it either passes the culture code which is required to be 'US' only, or we can pass the created date or modified date in the payload. This is a know issue in Salesforce. Also, the value for Opt In needs to be passed as '2', instead of 1. Refer SMS Subscription Log Data View.
Below is the Sample Payload.

    {
   "contactKey":"1234-ABC-456",
   "attributeSets": [{
         "name":"MobileConnect Subscriptions",
         "items": [{
               "values": [
                     { "name":"Keyword", "value":"6B2C6636-6235-4F20-A37DC68FCD1797F2"},
                      { "name":"Mobile Number", "value":"123456789"},
                     { "name":"Opt In Status", "value":2},
                     { "name":"Opt Out Status", "value":0},
                     {"name":"Modified Date", "value": "2020-09-22 10:00:03"}, 
                    {"name":"Created Date", "value": "2020-09-22 10:00:03"} 

               ]
         }]
   }]
}
0

The value of Keyword must be the KeywordID (it will be a 32 character key) - you can get it querying the Data View _SMSMessageTracking, like this:

select KeywordID from _SMSMessageTracking where Mobile = 'XXXXXXXXXX'

More details here: https://code4.cloud/articles/sfmc-unsubscribe-mobile-numbers-at-keyword-level-mobileconnect/

Good luck!

1

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.