Pass values from a flow deigner action script to a third party application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2023 08:52 AM
Hi,
I have a REST API Message - POST created to add values to the field on the third party application. But when i am trying to pass the values from the REST API i don't see the values to be updated on the third party application. I need to know how do we pass the values from REST API Message - POST to the third party application
Please refer to the below snapshot of the REST Message API:
The values added on the "HTTP Query Parameters" only gets updated on the third party application but not the values passed from the REST Message API script. How to bring the values from the flow designer action script to the "HTTP Query Parameters".
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2023 09:06 AM
I am a bit confused.
You are not able to send any request body which you have mentioned in the CONTENT section of REST Message or you are not able to send data from the flow designer to REST Message?
The way you have defined the variables, if you want to use those in the CONTENT, you have to access those with following syntax -
Content -
{
""BusinessAppID":"${businessApplicationIDVariable}",
"roleTypeID":"${roleTypeID}"
}
Also please do confirm as what kind of requestBody third-party application is expecting, you can remove the sensitive data & just share the correct format.
If it helps, do mark the response as HELPFUL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2023 09:41 PM
Hi @H S B @Sainath N
Below the code that i am using in the script action in the flow designer.
var roles = inputs.roles;
var busApp = inputs.busApp;
var curUsr = inputs.curUsr;
var newUsr = inputs.newUsr;
var requestor = inputs.requestor;
var addRmvUpd = inputs.addRmvUpd;
try {
var sendReq = new sn_ws.RESTMessageV2("ABC_API_Token", "Get_Token");
sendReq.setEndpoint("<Third Party Application API URL>");
sendReq.setStringParameterNoEscape("accesskey", "<Access Key>");
sendReq.setStringParameterNoEscape("clientid", "<Client ID>");
var initialResponse = sendReq.executeAsync();
var initialResponseBody = initialResponse.getBody();
var initialHttpStatus = initialResponse.getStatusCode();
var obj = JSON.parse(initialResponseBody);
var token = obj.token;
var sendReq = new sn_ws.RESTMessageV2("ABC_API_Add", "Add_Users");
sendReq.setEndpoint("<Third Party Application API URL>");
sendReq.setStringParameterNoEscape("businessApplicationEsatsId", busApp);
sendReq.setStringParameterNoEscape("requestorBemsId", requestor);
sendReq.setStringParameterNoEscape("roleTypeId", roles);
sendReq.setStringParameterNoEscape("userBemsId", newUsr);
sendReq.setStringParameterNoEscape("token", token);
var addUsrRes = sendReq.executeAsync();
var addUsrResBody = addUsrRes.getBody();
var addUsrhttpStatus = addUsrRes.getStatusCode();
gs.info("Inside Function - addUsrResBody: " + addUsrResBody);
gs.info("Inside Function - addUsrhttpStatus: " + addUsrhttpStatus);
}catch (ex) {
var message = ex.message;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2023 09:15 AM - edited ‎12-22-2023 01:31 PM
@Hari1 : What's the response code you are getting when you try passing the values from the content block?
@Hari1 :
Also, I noticed from your screenshot that your values from the key-value pair are not in quotes. Could you try adding quotes to all your values in the content?
Content -
{
"your_attribute_name" : "XXXX"
}
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2023 10:24 PM
Hi @Sainath N
I am trying to pass the variable values from the Flow Designer-Script Action to REST API Message. I am not able to get the variables passed from the script of the flow designer to the REST API Message.
Below the response that i am seeing in the log.
{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-f6312f6a50814e128933bd0bf2157685-d98eb7ed6c1bb2d0-00","errors":{"$.requestorBemsId":["'a' is an invalid start of a value. Path: $.requestorBemsId | LineNumber: 2 | BytePositionInLine: 19."]}}