Create new table row, HubDB API

developertools

#1

I have been trying to use the API to create a new row in a table based on this article here https://developers.hubspot.com/docs/methods/hubdb/create_row and I have been able to create a new row successfully, however they are always blank, I cant seems to get it to input data. I am new to the hubspot api and also JSON so maybe there is something really obvious ive done wrong here, I would be grateful for any input.

My Code:
var xhr = new XMLHttpRequest();
xhr.open(‘POST’, “https://api.hubapi.com/hubdb/api/v1/tables/(tableid)/rows?hapikey=(apikey)”, true);
xhr.setRequestHeader(‘Content-Type’, ‘application/json; charset=UTF-8’);
xhr.send(JSON.stringify({ “13”: “test” }));


#2

If anyone else has this problem, I found what was wrong. the send request need to look like this
xhr.send(JSON.stringify(
{
“values”: {
“1”: “name”,
“13”: “123”
}
}
));
I had the values part in there before, but it was all on one line and maybe there was something else wrong with it, but this has fixed it!


#3

I appreciate you coming back and posting the solution. thanks!