Docs error? Is JSON.stringify not needed for POST in V8?

HI, I spent some time trying to figure out why my POST request does not work in a V8 event script. Turned out I didn’t need to do JSON.serialize on payload object, just pass it ‘as is’. In the docs examples here a POST example in V8 serializes the payload, but in Node.js it doesn’t. Serializing the payload gave me :

"No record(s) detected in request. Please make sure record(s) are wrapped in a 'resource' tag.

Is the V8 example wrong or am I missing something?

Hi!

There is no serialization in V8 post example. At least for now. So, if it was before, now it is clear: you can pass object.

Wbr,

Gunnar

// V8js
 
var url = 'http://example.com/my_api';
var payload = JSON.stringify({"name":"test"});
var options = {
    'headers': {
        'Content-Type': 'application/json'
    },
    'parameters': {
        'api_key': 'my_api_key'
    },
};
var result = platform.api.post(url, payload, options);
var_dump(result);

I’m speaking of this fragment. There’s JSON.stringify on the payload. Right below is Node example without it.

Sorry, you were talking about payload, i was looking options.

That’s correct. JSON.stringify is not needed. I will update the docs.