The CreatorCon Call for Content is officially open! Get started here.

I Keep getting "status":400,"error":"Bad Request" but it works on POSTMAN

Folorunsho Ogin
Tera Contributor

I am just sending details of a record once it has been resolved to an Endpoint, which triggers an SMS notification sent to the User. I tried using the REST message and setting up the Business Rule, but it didn't work, so I decided to construct the payload directly within the Business Rule script. But I still get a 400 response 

NOTE: I used X to cover sensitive information, and I attached a screenshot showing that it works on Postman. I would really appreciate any help I can get with this.

 

(function executeRule(current, previous) {
try {
var r = new sn_ws.RESTMessageV2();

r.setEndpoint("xxxxxxxxxxxx"); 

r.setHttpMethod("POST");
 
/ Headers

r.setRequestHeader("Content-Type", "application/json");
 
r.setRequestHeader("x-api-key", "xxxxxxxxxxxxxxxxxxxxxxxxx");

r.setRequestHeader("surveyId", "xxxxxxxxxxxxxxxxxxxxxxxxx");

r.setRequestHeader("countryCode", "xxxx");
 

var body = {

"transactionID": current.number || "",

"customerEmailAddress": current.caller_id.email || "",

"customerSegment": "STANDARD",

"locationState": "NGA",

"interactionType": "Activation",

"callReasonArea": current.short_description || "",

"callReasonSubArea": "description: " + (current.description || "") + "; msisdn: " + (current.u_customer_name || "") + ";",

"timeofContact": current.sys_created_on || "",

"channelofInteraction": "NA",

"modeofInteraction": "NA",

"dateofInteraction": current.sys_created_on || "",

"agentID": current.caller_id.name || "",

"lob": "WALK-IN",

"customerName": current.u_customer_name || "",

"locationGeoPolitical": "NA",

"surveyType": "Postfeed",

"targetSystem": "VOC",

"tenureofCustomer": "NA",

"ninLinked": "NA",

"usim": "NA",

"phoneType": "NA",

"phoneModel": "NA",

"dateofBirth": "NA",

"tariffPlan": "NA"

};
 
r.setRequestBody(JSON.stringify(body));
var response = r.execute();

var responseBody = response.getBody();

var httpStatus = response.getStatusCode();
 
} catch (error) {
gs.error(" Survey Integration Error for incident " + current.number + ": " + error.message);
gs.error("Error stack trace: " + error.stack);
}
})(current, previous);
0 REPLIES 0