One more thing I noticed: Server API request data is not JSON format.
I tried to do
Server.setHttpHeader("content-type: application/json");
and still doesn't work.
var data = {
"name": "Iron Man",
"status": "Gone gone"
};
Server.setBaseURL("https://postman-echo.com/post");
Server.callWithPOST("/", data, function(status, response) {
Console.print(status);
if (status == Server.StatusOK) {
payload = response;
Console.print(JSON.stringify(response));
}
});
//echo back from server------------------------------------------------------------------------
{
"args": {
},
"data": "name=Iron%20Man&status=Gone%20gone",
"files": {
},
"form": {
},
"headers": {
"x-forwarded-proto": "https",
"x-forwarded-port": "443",
"host": "postman-echo.com",
"x-amzn-trace-id": "Root=1-60f17642-6b42c7eb593222a77e103b8c",
"content-length": "34",
"accept": "*/*",
"content-type": "application/json",
"user-agent": "juce",
"cache-control": "no-cache"
},
"json": null,
"url": "https://postman-echo.com/post/"
}
var data = {
"name": "Iron Man",
"status": "Gone gone"
};
Server.setBaseURL("https://postman-echo.com/post");
//Try to Set content-type to application/json
Server.setHttpHeader("content-type: application/json");
Server.callWithPOST("/", data, function(status, response) {
Console.print(status);
if (status == Server.StatusOK) {
payload = response;
Console.print(JSON.stringify(response));
}
});
//echo back from server------------------------------------------------------------------------
{
"args": {
},
"data": "name=Iron%20Man&status=Gone%20gone",
"files": {
},
"form": {
},
"headers": {
"x-forwarded-proto": "https",
"x-forwarded-port": "443",
"host": "postman-echo.com",
"x-amzn-trace-id": "Root=1-60f176e9-3369eaac39072e93338cd563",
"content-length": "34",
"accept": "*/*",
"content-type": "application/json",
"user-agent": "juce",
"cache-control": "no-cache"
},
"json": null,
"url": "https://postman-echo.com/post/"
}