hey, hope someone can help me with this. I know I’m missing something.
we are trying to integrate our Tadabase app with ShipStation so we can get orders, among other things.
I managed to pull the data from shipstation through their endpoint and using JavaScript. the issue I’m having is when I use tadabase endpoint to post the data i just got a “bad request” error. I tested tababase endpoint on postman so i know it works
here are the screenshots
Hi, I used the the TB API a lot, and sometimes it requires more Google script flavor rather than “pure” JS. I can give you an example that it’s working for me, I think the key point is the order of method, headers and payload in the settings variable, also using the function urlFetchApp.fetch instead of using fetch alone. Maybe you can try this.
var creado = [];
for (var i = 0; i < mismaCompany.length; i++) {
var doc = mismaCompany[i];
const GAP_URL = "https://api.tadabase.io/api/v1/data-tables/{gapTable}/records";
var payload = {
"iteration": i,
"field_108": doc["field_120"],
"field_109": lanzamiento,
"field_110": doc["field_122"][0],
"field_111": company,
};
creado.push(payload);
var settings2 = {
"method": "POST",
"headers": {
'X-Tadabase-App-id': appId,
'X-Tadabase-App-Key': apiKey,
'X-Tadabase-App-Secret': apiSecret,
},
"payload": payload
};
UrlFetchApp.fetch(GAP_URL, settings2);
}
I can see you are receiving a json from Shipstation, but you need to iterate thru TB to create the records, TB only creates 1 record at a time using the POST