1

Is there still no way to add subscribers via the REST API and/or Node.js?

Trying to build a very simple custom signup form to add emails to Email Studio. Am I going to have to use SOAP + PHP?

UPDATE:

So I tried making requests with Eliot's post data and Im getting 400 bad request. There are some differences with whats in the docs to some extent (obviously not just the placeholder values) https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/createContacts.htm

Can't get the request to go through for the life of me, matching the SF docs example 1:1 or not.

Using the NODE SDK (which im using to successfully get a token). Also tried using that token in Postman and I cant seem to get the formatting right. Below is the response I'm getting:

{
    "operationStatus": "FAIL",
    "rowsAffected": 0,
    "requestServiceMessageID": "edbf7daa-7c62-4141-a28c-a233f980f614",
    "responseDateTime": "2018-07-17T09:10:54.9836631-06:00",
    "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": "26910f46-f794-4886-9738-2aca1ec97bec"
}

UPDATE 2:

So I'm seeing the exact same errors, trying to perform the same action as fellow developer in this post. Looks like its on SF side of things and contacting support is necessary.

Yes, the issue was resolved but support intervention was necessary. If you reach out to support have them reference ticket 15740567. This problem problem stems from the SFMC account being incorrectly provisioned. They will need to add the HTML Enabled field to the Email Addresses system data data extension

1
  • 1
    I don't believe there is a direct way to do this, but you can place into a DE via REST and then use an automation or script activity to push the DE list into all subscribers. Commented Jul 16, 2018 at 20:47

1 Answer 1

2

Yes you can. The following REST API method will create an email Subscriber in All Subscribers list (and also add them as a Contact in All Contacts).

In the example below, "123456789" will be used as the Subscriber Key value (and the Contact Key in All Contacts).

Note that the values array in the Email Demographics object (Last Name, First Name, etc) are example profile attributes used in All Subscribers. You can remove these if you are not using profile attributes.

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

{
   "contactKey":"123456789",
   "contactId":null,
   "attributeSets":[
      {
         "name":"Email Addresses",
         "items":[
            {
               "values":[
                  {
                     "name":"Email Address",
                     "value":"[email protected]"
                  }
               ]
            }
         ]
      },
      {
         "name":"Email Demographics",
         "items":[
            {
               "values":[
                  {
                     "name":"Last Name",
                     "value":"Sample"
                  },
                  {
                     "name":"First Name",
                     "value":"Sam"
                  },
                  {
                     "name":"Text Profile Attribute",
                     "value":"value 1"
                  },
                  {
                     "name":"Number Profile Attribute",
                     "value":12345
                  }
               ]
            }
         ]
      }
   ]
}
6
  • Thanks so much for this! I couldnt find any info on adding to a specific list other than All Subscribers. Is that possible as well? Lastly, do you recommend a particular method to generating a proper contactKey? Commented Jul 17, 2018 at 14:06
  • Thanks for the info Eliot! I was unaware this would also push into All Subs in Email Studio. I thought it would only be entered into data extension inside of Contact Builder These resources work only with data extensions that are linked in an attribute group in Contact Builder.. Looking into it a bit further, you are 100% correct on it - I should have known better than to believe SFMC on its own documentation. ha ha. Commented Jul 17, 2018 at 15:07
  • Hey I updated my original question if you feel like taking a look Commented Jul 17, 2018 at 15:16
  • @Gortonington, I was a little surprised myself. I stumbled on it a couple of years ago and thought "surely this won't work" but it actually does. And you can use the update method to update a Subscriber too. Commented Jul 17, 2018 at 21:47
  • @HauntedSmores, this should definitely work but I agree, it appears to be a provisioning issue. Keep me posted on that, but in the meantime, please can you accept my answer for the benefit of others? Commented Jul 17, 2018 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .