How to insert a row through the API?

Hi guys,

This should be fairly simply, but I am unable to get it to work. I went through through the community posts to find an answer, but there aren’t many answered posts in regards to the API.

I’ve been using the API for a doc with Javascript, and have been successful so far for all calls that did not include any extra data / payload. All the GET and single DELETE calls work fine.

However, I am now struggling with getting a simple POST call to work, in order to insert a row in the table.

I keep on getting a 400 (Bad Request) error every time I try to call it.

Am I writing this wrong?

  let testData = {
'rows': [
    {
        'cells': [
            {'column': 'c-GQELzj3QQm', 'value': 'test'},
            {'column': 'c-ynl5mcaRjk', 'value': '#039BC3'}
        ]
    },
    {
        'cells': [
            {'column': 'c-GQELzj3QQm', 'value': 'test2'},
            {'column': 'c-ynl5mcaRjk', 'value': '#99beE1'}
        ]
    }
]
}

  function AddSingleRow() {
$(document).ready(function () {
  $.ajax({
    url: urlStart + WarehouseMapId + "/tables/" + TestTableId + "/rows/",
    type: "POST",
    data: testData,
    headers: {
      "Authorization": token
    },
    success: function (result) {
      console.log("Deleted row: " + selectedRowsPayload)
    },
    error: function (error) {
      alert(error);
    }
  });
});
  };

Hi @Max_Pauwels. Have you resolved this issue. I was also trying to add row through api but it is giving me 400 error. Can you tell me how to overcome this issue. Thanks

Hi @Abhishek_Akant @Max_Pauwels
I have the same issue, if you found a solution it would be a lifesaver.
Thx.

@Galdric_Fleury every time I got a Bad Request error it was because I was trying to insert rows into a table that did not already have the column existing.

Even sometimes I thought I already had the column created, but every time, that ended up being the problem. After checking the table in coda, I find that the column doesn’t actually exist with that exact name/id.