Hi Team,
I want to set the customized Target Server Error msg after manipulating in the Java script policy.
Below code in javascript:
if(respstCode==401 && respContent.includes("The supplied credentials were incorrect")){ context.setVariable('TargetServerError','The supplied credentials were incorrect'); } else{ context.setVariable('TargetServerError','Internal Server Error'); }
Code in Assign message policy:
Assign the values dynamicaly : TargetServerError, respcode
<AssignMessage... > ... <AssignVariable> <Name>flow.myapi.error.status</Name> <Ref>fault.status</Ref> <Value>{respcode}</Value> </AssignVariable> <AssignVariable> <Name>flow.myapi.error.message</Name> <Ref>fault.message</Ref> <Value>{TargetServerError}</Value> </AssignVariable> ...
I am not able to see the values in the assign message policy.
Please suggest me to customize the dynamic error from target end point.
Thanks,
Kumar
Solved! Go to Solution.
Hi @kumar -- See if this helps unblock you on using the AssignMessage policy.
In this example, AssignVariable creates a new flow variable flow.myapi.error.message and assigns to it the value of the flow variable TargetServerError (which you create in your JavaScript). If that flow variable does not exist, it assigns the string foo.
<AssignVariable> <Name>flow.myapi.error.message</Name> <Ref>TargetServerError</Ref> <Value>foo</Value> </AssignVariable>
Hi Kumar,
In JavaScript, you have set the error message to TargetServerError variable
In AssignMessage policy you should assign the setVariable to reference element, then it will work.
<AssignVariable> <Name>flow.myapi.error.message</Name>
<Ref>TargetServerError</Ref>
<AssignVariable>
Thanks
Hi @kumar -- See if this helps unblock you on using the AssignMessage policy.
In this example, AssignVariable creates a new flow variable flow.myapi.error.message and assigns to it the value of the flow variable TargetServerError (which you create in your JavaScript). If that flow variable does not exist, it assigns the string foo.
<AssignVariable> <Name>flow.myapi.error.message</Name> <Ref>TargetServerError</Ref> <Value>foo</Value> </AssignVariable>
Thanks you very much.
Hi Kumar,
In JavaScript, you have set the error message to TargetServerError variable
In AssignMessage policy you should assign the setVariable to reference element, then it will work.
<AssignVariable> <Name>flow.myapi.error.message</Name>
<Ref>TargetServerError</Ref>
<AssignVariable>
Thanks
Thanks you very much.