Creating new entries using curl and JSON with Airtable API

I can successfully retrieve data from Airtable, but I’m struggling to create new entries using curl commands.

The official Airtable documentation provides this working example:

curl -v -XPOST https://api.airtable.com/v0/appXY123def/Products \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-type: application/json" \
-d '{
  "fields": {
    "ProductID": "ABC123-DEFG",
    "Description": "Sample item"
  }
}'

This works perfectly when I copy it directly. However, when I modify any values (like changing the ProductID), I get this error:

{"error":{"type":"INVALID_REQUEST_BODY","message":"Could not parse request body"}}

Even simple text changes cause this parsing error. What could be causing this issue with the request formatting?

Had this exact problem last month when automating our product catalog updates. It’s usually the JSON structure that’s messed up.

First - make sure your JSON is properly escaped. When you change values, you might accidentally break the JSON syntax. Use a JSON validator to check your payload before sending.

Another common cause is the Content-Type header. Sometimes it gets mangled when copying commands. Make sure it’s exactly application/json without extra spaces or characters.

Try building your JSON in a separate file first, then reference it in curl:

curl -XPOST https://api.airtable.com/v0/appXY123def/Products \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d @payload.json

This way you can verify your JSON is valid before sending. Also double check your field names match exactly what’s in your Airtable base - case sensitive and everything.

yea, it sounds like you might be copying some weird chars. try just typing it out instead of pasting. watch out for quotes too, straight ones are a must! those curly ones really mess things up sometimes.

This error usually comes from hidden characters or encoding problems in your JSON. I hit the same issue using curl on Windows - PowerShell handles quotes weird. Try escaping quotes properly or switch terminals if you’re on Windows. Line breaks in your JSON structure also cause this. Format your JSON as one line or use backslashes to escape breaks. Validate your JSON with an online tool before running curl. Sometimes copying from docs adds invisible Unicode characters that mess up parsing.