0

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?

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.

2

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

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.