Is this possible to use Assign Message policy to access Javascript variable over NO target API??
Hi @Mir Mehran Khan, in JS policy we have context object. The context
object has a global scope. It is available everywhere within the API proxy flow.
For example, the following JavaScript code example uses the context.flow
property and calls the get/setVariable() methods oncontext
.
if(context.flow=="PROXY_REQ_FLOW"){ var username = context.getVariable("request.formparam.user");
context.setVariable("USER.name", username); }
The context.setVariable Sets the value for a custom variable. Now you can use USER.name flow variable in Assign Message policy.
Question was missing a lot of details ,but from what what i understood , you want to utilize values from javascript to generate response for a no target API using assign message policy.
You can directly access Javascript variable in assign message policy without EV policy using context object.
context is a global scope object available everywhere in API proxy flow.
so you can set variables in context from javascript and access them in assign message.
var era = context.getVariable("request.formparam.blade_runner"); if( era != 2049){ context.setVariable("blade_runner_era", "2049"); }else{ context.setVariable("blade_runner_era", era); }
AssignMessage
<Set> <Payload contentType="application/json"> {"Location":"Los Angeles", "Year":"{blade_runner_era}"} </Payload> </Set>
Please take refrence of this for full documentation for variable access in Assign Message.
Hope this will help !!!!
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |