I am attempting to insert a contact to a data extension via PHP, but it is resulting in a 400 bad request. I've placed my request in a try catch statement and what I get back is:

      "messageFormatString":"Unable to resolve schema element of type: {0} by reference. [Id: {1}, Key: {2}, Name: {3}]",
      "message":"Unable to resolve schema element of type: SetDefinition by reference. [Id: , Key: , Name: 2CE886EF-8169-4D57-9EC1-018BCB6DB2F0]"

It isn't really clear what the error is, Unable to resolve schema element of type: {0} by reference. ?? What is type {{0}}? That appears to be a placeholder that isn't resolving.

I am using Guzzle to make the API request. I formatted my data just like the payload example shown here: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/createContacts.htm

$httpClient = new Client();

$user = [
  'contactKey' => 'ronnieswietekronnie@ms.com',
  'attributeSets' => [[
    'name' => '2CE886EF-8169-4D57-9EC1-018BCB6DB2F0',
    'items' => [[
      'values' => [
        ['name' => 'email', 'value' => 'ronnie@ms.com'],
        ['name' => 'HTML Enabled', 'value' => 'true'],
        ['name' => 'first_name', 'value' => 'ronnie'],
        ['name' => 'last_name', 'value' => 'swietek'],

try {
  $options = [
    RequestOptions::HEADERS => [
      'Content-Type' => 'application/json',
      'Authorization' => 'Bearer ' . $config->get('token'),
    RequestOptions::BODY => Json::encode($user),
  $response = $httpClient->request('POST', 'https://www.exacttargetapis.com/contacts/v1/contacts', $options);
} catch (\GuzzleHttp\Exception\RequestException $e) {

The user object in json format looks like this:

              "name":"HTML Enabled",

at a guess, I would say that you are using an external ID and not the attribute set name because 2CE886EF-8169-4D57-9EC1-018BCB6DB2F0 would be a little strange to put as a name in data designer :D secondly, from the way I read the site, only certain values are allowed, which kind of makes sense as this is creating specific type of data (namely a contact)

from: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/createContacts.htm

The request must include at least one of the attribute sets to create a new contact:

Email Addresses (You must also include this attribute set if you include Email Demographics)
MobileConnect Demographics (You must include a country code for the Locale value)
MobilePush Demographics (You must include an ApplicationID value)

Each call accepts only one instance of each attribute set.

From the example you post, maybe the names you want are "Email Addresses" and "Email Demographics" (yes, you will need both attribute sets, exactly like in the example).

If you are trying to just add data to a data extension you are more likely looking for

  1. Add Data to Data Extension plus trigger event in Journey Builder: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/contactEvents.htm or
  2. Add Data to Data Extension: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/insertDataExtensionIDAsync.htm
| improve this answer | |
  • I ended up using the wrong rest resource for what I was trying to do. I wanted to input data into a data extension and the route I needed ended up being developer.salesforce.com/docs/… I also tried option 2 but that wasn't working either – Ronnie Jan 18 '18 at 18:13

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.