Extracting variables from parameter query not working

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:

5980-screen-shot-2017-11-22-at-110958.png

- 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 Solved
0 3 3,121
1 ACCEPTED SOLUTION

Not applicable

@kevinanderson

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>

View solution in original post

3 REPLIES 3

Not applicable

@kevinanderson

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>

@Muhammad Imran Khan is right .. Kindly review the attachments

policy-xml.png

trace.png

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!