The Zurich release has arrived! Interested in new features and functionalities? Click here for more

data send to rest post method message using flow designer

chandan2212
Tera Contributor

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?

 

(function execute(inputs, outputs) {
    var phonenumber = inputs.phonenumber;
    var workphone = inputs.workphone;

    try {
        var r = new sn_ws.RESTMessageV2('xyz rest message', 'post message');

        // If you're using parameters in the REST message body template
        r.setStringParameterNoEscape('phonenumber', phonenumber);
        r.setStringParameterNoEscape('workphone', workphone);

        // Alternatively, if you're building the body manually:
        // var requestBody = JSON.stringify({
        //     "phonenumber": phonenumber,
        //     "workphone": workphone
        // });
        // r.setRequestBody(requestBody);

        var response = r.execute();
        var responseBody = response.getBody();
        var httpStatus = response.getStatusCode();

        // Optionally log or output the response
        outputs.responseBody = responseBody;
        outputs.httpStatus = httpStatus;
        output.responseBody=responseBody;
    } catch (ex) {
        var message = ex.message;
        outputs.error = message;
    }
})(inputs, outputs);
 
while the script i am receiing the status code :
 
{ "Action Status": { "code": 0, "message": "Success" } }
 
 
I amreceving the three logs :
 
2025-09-26 02:54:35WarningEncountered undeclared output variable: error
2025-09-26 02:54:35WarningEncountered undeclared output variable: httpStatus
2025-09-26 02:54:35WarningEncountered undeclared output variable: responseBody
 
Can you help me how to resolve the problem.
 
 
Thanks and Regards,
Chandan 
 
 
1 ACCEPTED SOLUTION

Missing s in output:

 outputs.responseBody=responseBody;

 

View solution in original post

5 REPLIES 5

chandan2212
Tera Contributor

another output message is coming :

error :"output" is not defined.

Missing s in output:

 outputs.responseBody=responseBody;

 

Anand2799
Giga Guru

Hi @chandan2212 ,

 

Under the script action you need to defined your variables in output variables section.

Anand2799_0-1758865907508.png

 

Thanks

Anand

Hi @chandan2212 ,

 

If this solves your query mark this as correct to close the thread.