I am trying to assign a default value of the query parameter request.queryparam.results
I am using the query parameter in callouts but get 500 responses when request.queryparam.results=null.
If I use 'set' in Assign Message Policy I overwrite the value which is not what I won't if it is different from null.
How can I set a default value of the parameter?
Solved! Go to Solution.
I really like using a simple javascript callout for this sort of thing. The ternary operator makes it pretty easy to one-line this.
context.setVariable('request.queryparam.results', context.getVariable('request.queryparam.results') ? context.getVariable('request.queryparam.results') : 0)
This works for me in a single Assign Message and for multiple params @Anders Bilfeldt @Carlos Eberhardt
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Default-Query-Params"> <DisplayName>Assign Default Query Params</DisplayName> <FaultRules/> <Properties/> <AssignVariable> <Name>request.queryparam.format</Name> <Value>json</Value> <Ref>request.queryparam.format</Ref> </AssignVariable> <AssignVariable> <Name>request.queryparam.offset</Name> <Value>0</Value> <Ref>request.queryparam.offset</Ref> </AssignVariable> <AssignVariable> <Name>request.queryparam.limit</Name> <Value>10</Value> <Ref>request.queryparam.limit</Ref> </AssignVariable> ...