Creating record returns 406 INVALID_ACCEPT_HEADER

First of all, is the Record topic of the docs missing an Attributes section? The other topics all seem to start with Attributes, but nothing for records.

I am sending an HTTP POST to https://site-api.datocms.com/items to create a new record but regardless of what I try, the only result ever returned is a 406. I issued a GET request against the same model, copied and pasted the attributes back, minus the created one and still receive a 406. Here is my request with the apikey obfuscated.

POST https://site-api.datocms.com/items HTTP/1.1
X-Api-Version: 3
Authorization: Bearer xxx
Accept: application/json
Content-Type: application/json

{
  "data": {
    "type": "item",
    "attributes": {
      "first_name": "Troy",
      "last_name": "Forster",
      "email_address": "troy.forster@gmail.com",
      "phone_number": "4166174921",
      "salesforce": "",
      "results": [
      ]
    },
    "meta": {},
    "relationships": {
      "item_type": {
        "data": {
          "id": "199010",
          "type": "item_type"
        }
      }
    }
  }
}

Everything looks good there.

Can you please share some code that I can run to reproduce your call? Even just a curl call?

face+palm

I had a blank line between the request and the headers in my VSCode that I cleaned up when I posted the sample above. The RESTClient extension I use, as a quick-n-dirty convenience over PostMan, sees the line break as ending the request AND headers. Everything that follows is interpreted as the body.

Remove the line break and now I’m getting back a clean response from Dato.

EBKAC - sorry

1 Like

no worries!! :slight_smile: