MarketingCloud – Creating Contact via API problem

I’ve found a similar question, but I could not find any real solutions for the issue.

We have a DataExtension with the following attributes:

"ID"                   Number
"Email"                EmailAddress  254
"LanguageID"           Locale          5
"Unsubscribed"         Boolean
"Promotion code sent"  Boolean
"T_OptedIn"            Boolean

I’ve inserted the following row to the DataExtension:

"ID"                   "415111"
"Email"                "sampleEmail@somedomain.com"
"LanguageID"           "hu-HU"
"Unsubscribed"         "False"
"Promotion code sent"  "False"
"T_OptedIn"            "False"

In the contact builder we’ve made a link “ContactKey to Email”.
Contact and DataExtension link

The reference states “The request must include at least one of the attribute sets to create a new contact” and “Email Addresses (You must also include this attribute set if you include Email Demographics)”

I’ve assembled the following JSON:

{
    "contactKey": "sampleEmail@somedomain.com",
    "attributeSets": [{
        "name": "Email Addresses",
        "items": [{
            "values": [{
                "name": "Email Address",
                "value": "sampleEmail@somedomain.com"
            },
            {
                "name": "HTML Enabled",
                "value": true
            }]
        }]
    }]
}

I’ve managed to successfully get a access token for our ClientId/ClientSecret key pair.

Then assembled this CURL command:

curl -X POST --header "Content-Type:application/json" --header "Authorization: Bearer {{MY_TOKEN}}" -d "{\"contactKey\":\"sampleEmail@somedomain.com\",\"attributeSets\":[{\"name\":\"Email Addresses\",\"items\":[{\"values\":[{\"name\":\"Email Address\",\"value\":\"sampleEmail@somedomain.com\"},{\"name\":\"HTML Enabled\",\"value\":"true"}]}]}]}" "https://www.exacttargetapis.com/contacts/v1/contacts"

Host: https://www.exacttargetapis.com
POST /contacts/v1/contacts
Content-Type: application/json
Authorization: Bearer {{MY_TOKEN}}

{
    "contactKey": "sampleEmail@somedomain.com",
    "attributeSets": [{
        "name": "Email Addresses",
        "items": [{
            "values": [{
                "name": "Email Address",
                "value": "sampleEmail@somedomain.com"
            },
            {
                "name": "HTML Enabled",
                "value": true
            }]
        }]
    }]
}

And this was the response:

{
  "operationStatus": "FAIL",
  "rowsAffected": 0,
  "requestServiceMessageID": "36f006b9-c6e0-4d8f-8907-e8ef785f0a9f",
  hasErrors": true,
  "resultMessages": [{
      "formatStringParams": [
        "ValueDefinition",
        null,
        null,
        "HTML Enabled"
      ],
      "messageFormatString": "Unable to resolve schema element of type: {0} by reference. [Id: {1}, Key: {2}, Name: {3}]",
      "resultType": "Validation",
      "resultClass": "Error",
      "resultCode": "SchemaObjectNotFoundByReference",
      "message": "Unable to resolve schema element of type: ValueDefinition by reference. [Id: , Key: , Name: HTML Enabled]"
    }],
  "serviceMessageID": "b1c2fbe6-1a95-4802-b838-1ff817ea08eb"
}

Also, here is the DataAccess for our API Integration
Data Access

I really hope there is a solution to this issue.

Answer

We had some problem with the attribute “HTML Enabled” when importing contacts via import file wizard. May be the same solution will work here.

Instead of this
{
“name”: “HTML Enabled”,
“value”: true
}]

Can you try using this,
{
“name”: “HTML Enabled”,
“value”: “HTML”
}]

or
{
“name”: “HTML Email”,
“value”: “HTML”
}]

Attribution
Source : Link , Question Author : Laszlo , Answer Author : Praveen Kumar Bandi

Leave a Comment