Hi there, I have a Javascript policy for generating a random string code, then I use a ServiceCallout with a XML payload where I am trying to include the generated code. For that I use an expression like this:
<Payload contentType="application/xml"> <BODY TYPE="TEXT">{context.getVariable("mycode")}</BODY> </Payload>
but the target receives `{context.getVariable("mycode")}` instead of the actual variable content.
Solved! Go to Solution.
In JS Policy, you use context.getVariable to retrieve apigee flow variables into JS code. If you want to set new variable use context.setVariable
var responseCode = properties.source; // Returns "response.status.code" var value = context.getVariable(responseCode); // Get the value of response.status.code context.setVariable("javier", value);
As per the above example if you want to use javier value from - context.setVariable("javier", value);in Service callout policy,
<Payload contentType="application/xml"> <BODY TYPE="TEXT">{javier}</BODY> </Payload>
In JS Policy, you use context.getVariable to retrieve apigee flow variables into JS code. If you want to set new variable use context.setVariable
var responseCode = properties.source; // Returns "response.status.code" var value = context.getVariable(responseCode); // Get the value of response.status.code context.setVariable("javier", value);
As per the above example if you want to use javier value from - context.setVariable("javier", value);in Service callout policy,
<Payload contentType="application/xml"> <BODY TYPE="TEXT">{javier}</BODY> </Payload>
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |