I've copied and modified the sample code for extracting a variable from a query parameter:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="true" enabled="true" name="Extract-Variables-Query-Param"> <DisplayName>Extract Variables - Query Param</DisplayName> <Source>request</Source> <QueryParam name="appt_number"> <Pattern ignoreCase="true">{appt_number}</Pattern> </QueryParam> <VariablePrefix>queryinfo</VariablePrefix> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </ExtractVariables>
And this is the URL itself:
http://myproxy.apigee.net/basepath/?appt_number=123
Unfortunately, the data "123" from the query param "appt_number" isn't being picked up. When I try and find the variable queryinfo.appt_number in a trace, it's empty:
- all you see is the variable prefix.
As it's an almost verbatim copy of the sample, it should work - so what's missing?
Solved! Go to Solution.
You must remove prefix variable to see your value in trace. Although it is not necessary to get query param value using extract variable. You can access it directly like request.queryparam.<param_name>
You must remove prefix variable to see your value in trace. Although it is not necessary to get query param value using extract variable. You can access it directly like request.queryparam.<param_name>
Yep, absolutely right (if a tad counter-intuitive), remove <VariablePrefix> from the policy, and you can put as many data elements in your query string as you like.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="true" enabled="true" name="Extract-Variables-Query-Param"> <DisplayName>Extract Variables - Query Param</DisplayName> <Source>request</Source> <QueryParam name="appt_number"> <Pattern ignoreCase="true">{appt_number}</Pattern> </QueryParam> <QueryParam name="astatus"> <Pattern ignoreCase="true">{astatus}</Pattern> </QueryParam> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </ExtractVariables>
http://myproxy.apigee.net/basepath/?appt_number=123&astatus=pending
Now both "123" and "pending" come through as values for the appropriate variables in the above. Nice!
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |