1

I have a data extension which do not have any primary key. I need to add new records via API to that data extension. How can I achieve that?

2 Answers 2

4

As far as I know you can't add a record to a data extension without a primary key via the REST API. To get around this you could set a primary key on the data extension and just generate a unique key in the code that sends the data via API.

10

I had this question too and came across this thread.

Wanted to give an update that you can actually insert data into a data extension without a primary key using REST API.

What you need to use is Async Insert istead of Sync Insert. This feature is probably disabled on your Account. Just create a support case and ask them to enable it based on your usecase.

This method works like a charm for me

POST /data/v1/async/dataextensions/{id}/rows

Example Request:

    Host: https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com
    POST /data/v1/async/dataextensions/key:ExternalKey12345/rows
    Content-Type: application/json
    Authorization: Bearer YOUR_ACCESS_TOKEN

    {
       "items": [{
          "FirstName":"Bobby",
          "LastName" : "Jones",
          "ZipCode": "23456"
       },
       {
          "FirstName":"Sam",
          "LastName" : "Sneed",
          "ZipCode": "23456"
       }]
    }

Here's the doc: https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/data-extensions-api.htm

1
  • Now here's a comment I wish I'd read 2 years ago. Thank you for sharing your insight. I had no idea this path and /hub/v1/dataevents/key:{key}/rowset were different in this way! Commented Sep 4, 2020 at 21:40

You must log in to answer this question.

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