Features Marketing Cloud - Uncategorized

Add Data into Data Extension via REST API

There are numerous scenarios in which rows of data must be upserted into a data extension via API. Writing to a data extension directly provides access without requiring the Website Manager skills.

First you’ll need to create the API endpoint by creating an Installed Package in SFMC setup. Plus the read/write privileges to data extensions specifically for this API call. Once done, use the authorization end point to get the Bearer token which will be needed to data rows into the DE.

The endpoint is:

/data/v1/async/dataextensions/key:[data_extension_key/rows

For example, the full URL would be similar to this where “uniqueprefixhere” is the auto-generated prefix created when an Installed Package is created. And where [data_extension_key] is the customer key or unique key for the DE.

https://uniqueprefixhere.auth.marketingcloudapis.com/data/v1/async/dataextensions/key:[data_extension_key/rows

Here are several Postman samples for testing the API endpoint. First, change the Authorization type to Bearer Token, and then enter the value from the previous article here.

Then, under the Headers, set the Content-Type to application/json. In the next screenshot example, we will use raw json.

Depending on what data you need to add to the data extension, the structure of the data is shown in the raw JSON example below. You must, of course, include primary keys or non-nullable fields otherwise the result will fail.

JSON payload for insertion into Data Extension

The right response is 202. Accepted response with result Id and message details. In the SFMC user interface, verify that the row was added into the data extension.

Leave a Reply

Your email address will not be published. Required fields are marked *