post Rest message script in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2025 10:40 PM
Hi all ,
I am using a REST message with the POST method in Flow Designer. I am sending two input fields: phonenumber and workphone. I have created the REST message, set the endpoint, and configured basic authentication. Below is the preview script I’m using:
Can anyone confirm whether this script is correct or needs improvement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2025 10:51 PM
It looks good to go.
If you copied the code sample from your post method of the rest outbound message, you will get correct values for 'rest message' and 'post message' in the line below.
var r = new sn_ws.RESTMessageV2('rest message', 'post message');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2025 12:43 AM - edited 09-26-2025 12:44 AM
try something like this
(function execute(inputs, outputs) {
var phonenumber = inputs.phonenumber;
var workphone = inputs.workphone;
try {
var r = new sn_ws.RESTMessageV2('rest message', 'post message');
// Option 1: Using parameters if placeholders exist in REST message body
r.setStringParameterNoEscape('phonenumber', phonenumber);
r.setStringParameterNoEscape('workphone', workphone);
// Option 2: OR build request body directly (if no placeholders)
// var requestBody = JSON.stringify({
// "phonenumber": phonenumber,
// "workphone": workphone
// });
// r.setRequestBody(requestBody);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
outputs.responseBody = responseBody;
outputs.httpStatus = httpStatus;
if (httpStatus !== 200) {
outputs.error = "Unexpected HTTP status: " + httpStatus;
}
} catch (ex) {
outputs.error = ex.message;
}
})(inputs, outputs);
