I think I am in the API twilight zone

Honestly, I’m ready to pull my hair out.

I’ve been trying to put a reasonably complicated API call together. Was running into problems.
So I simplified.
And simplified.
And simplified.
And simplified.
And simplified.

Now I’m just in Postman, running the most basic GET and POST commands possible.

GET: a list of rows in a table.
POST: a new row to the same table.

The GET works no problem. I can list the tables in a doc, the rows in a table, specific rows in the table, whatever I need.

But the POST just throws me a 400 error:

{
“statusCode”: 400,
“statusMessage”: “Bad Request”,
“message”: “Missing required field "rows".”
}

This happens even if I copy/paste the payload straight from the Coda API page, adjust the column IDs, and press send.

wHaT tHe HeLL Am I DoInG WrOnG???

(P.S. I’m owner of the doc; I’m on a Pro plan)

Hi @Matthew_Shane !

Can you please share the body of your request here? It will be useful to see what and how you are sending it to spot if something is wrong.

Sure thing.

GET: https://coda.io/apis/v1/docs/XXXXXXXXXX/tables/grid-qjiZCq7IUk/columns

This works (with the correct doc ID, of course), gives me my column IDs, which are:

c-1fjnS-rAOP
c-dW_WToXs5D
c-VKcl3Ktcqp
c-g7Cbdan6U8

And then the resultant POST: https://coda.io/apis/v1/docs/XXXXXXXXXX/tables/grid-qjiZCq7IUk/rows

with the column IDs in the body:

{
  "rows": [
    {
      "cells": [
        {"column": "c-1fjnS-rAOP", "value": "cell_value_1"},
        {"column": "c-dW_WToXs5D", "value": "cell_value_2"},
        {"column": "c-VKcl3Ktcqp", "value": "cell_value_3"},
        {"column": "c-g7Cbdan6U8", "value": "cell_value_4"}        
      ]
    },
  ]
}

causes a 400 every time

{
“statusCode”: 400,
“statusMessage”: “Bad Request”,
“message”: “Missing required field "rows".”
}

Clearly I’m doing something wrong, but I’m done trying to figure out what it is (and GPT seems unable to help either)

Doc ID is right
Table ID is right
Column IDs are right (and just in case, I tried with column IDs without the “c-” to same effect.

Please tell me what I’m doing wrong so that I can keep the small amount of hair I have left. :wink:

How do you have the body configured in Postman? As raw?

Yup, raw. :person_shrugging:

Do I need to elevate this stupid thing to Coda support? :slightly_smiling_face:

@Eric_Koleda may be able to help :slight_smile:

Try removing the comma here? You can have that in JS but not JSON.

Also make sure you have the header Content-Type: application/json

I hope I’ve come in time for some hair to remain.

3 Likes

Good eyes @Paul_Danyliuk! I think the Missing required field "rows" error is due to not having the Content-Type header set to application/json. However once that it fixes you’ll get a different JSON parsing error until you remove the comma.

2 Likes

OMG it worked.

Thank you Paul!

(So sorry to everyone for having to get involved in something so basic; but really appreciate the help!)

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.