question

traineegurgaon avatar image
traineegurgaon asked

POST request not working from cloudscript.

Here is my code:-

var url = "http://ec2-18-221-14-69.us-east-2.compute.amazonaws.com:8080/clanclub/getUserName"var method = "post"; var contentBody = "";

var contentType = "application/json"; var headers = {};

log.info("This is a log statement!"); var responseString = http.request(url,method,contentBody,contentType,headers);

return {responseMessage : responseString}

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Here you go - this version works fine:

  var url = "http://ec2-18-221-14-69.us-east-2.compute.amazonaws.com:8080/clanclub/getUserName";
  var method = "post";
  var contentBody = JSON.stringify("");
  var contentType = "application/json";
  var headers = {}; 
  log.info("This is a log statement!");
  var responseString = http.request(url,method,contentBody,contentType,headers);
  return {responseMessage : responseString};
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.