When trying to post to a API using server-side scripting, I get error 400. When I copy the request to the API Docs, it works.
Here is the error message:
{ error:
{ code: 400,
context: null,
message: 'No record(s) detected in request. Please make sure record(s) are wrapped in a \'resource\' tag. Example: {"resource":[{"record":1},{"record":2}]}',
status_code: 400 } }
Here is the code:
var rows = [];
for (var item in c) {
rows.push({'id': id, 'id2': parseInt(c[item], 10) });
}
platform.api.post(url, {"resource": rows }, null, function(body) {
var results = JSON.parse(body);
console.log(results);
});
Any help would be appreciated.