Hello,
I've created a simple script for sending a POST request to an API with the "application/x-www-form-urlencoded" content type. Here's the script:
var http = new HttpClientRequest("URL");
http.header["Content-Type"] = "application/x-www-form-urlencoded";
http.header["Cache-control"] = "no-cache";
http.header["Connection"] = "keep-alive";
http.body = "param1=value1¶m2=value2¶m3=value3¶m4=value4";
http.method = "POST";
http.execute();
logInfo(http.response.code);
logInfo(JSON.stringify(http.response));
http.disconnect();
When I run this script, I receive a response with a 200 status code, but the response body is empty.
I've reached out to the API technical team, and they have tested the API from their end. They confirmed that they are receiving the request correctly and sending a proper response.
Please note that we have also added the URL to the "urlpermissions" in the control panel.
Could this issue be related to the "application/x-www-form-urlencoded" content type? I would appreciate it if someone could review this and share their thoughts.
Screenshot:
Thank you,
Krishna
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Could you please try printing the body of the response, as "var result = http.response.body.toString();" or if the response is in JSON object try parsing it and then printing them "var result3 = JSON.parse(http.response.body);" . Also you can try the same connection once in POSTMAN to see a clear picture and connection parameters.
Regards
Akshay
Could you please try printing the body of the response, as "var result = http.response.body.toString();" or if the response is in JSON object try parsing it and then printing them "var result3 = JSON.parse(http.response.body);" . Also you can try the same connection once in POSTMAN to see a clear picture and connection parameters.
Regards
Akshay
"var result = http.response.body.toString();" this worked. Not sure why the JSON.stringify had an issue with this.
Thanks for the inputs.
Views
Replies
Total Likes
Views
Likes
Replies