Dear Team
Greetings !
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Ext"> <DisplayName>ExtractVariables.Ext</DisplayName> <URIPath name="refnumber"> <Pattern>**/pay/{refnumber}/{txnnumber}/{sequencenumber}/{modeofpay}</Pattern> </URIPath>
Please note as above there are multiple URI and only able to retrieve {refnumber} .
Unable to retrieve full URI "variables"
I tried many trials but could not achieve same-
Even simplest help is appreciated 🙂
Best Regards
Sujith Mathew
Solved! Go to Solution.
If you are trying to get values for each variation, then you would need to provide patterns for each as well. I changed Dino's Extract Variables to use:
<URIPath> <Pattern ignoreCase="true">**/pay/{refnumber}</Pattern> <Pattern ignoreCase="true">**/pay/{refnumber}/{txnnumber}</Pattern> <Pattern ignoreCase="true">**/pay/{refnumber}/{txnnumber}/{sequencenumber}</Pattern> <Pattern ignoreCase="true">**/pay/{refnumber}/{txnnumber}/{sequencenumber}/{modeofpay}</Pattern> </URIPath>
Also changed the Assign Message good response to:
<Set> <Payload contentType="application/json">{ "variables":"{refnumber}/{txnnumber}/{sequencenumber}/{modeofpay}" } </Payload> <StatusCode>200</StatusCode> <ReasonPhrase>OK</ReasonPhrase> </Set>
Then all of these will populate appropriate values:
$ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1/2/3/4 { "variables":"1/2/3/4" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1/2/3 { "variables":"1/2/3/" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1/2 { "variables":"1/2//" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1 { "variables":"1///" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/foo/pay/1 { "variables":"1///" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/foo/bar/pay/1 { "variables":"1///" }
But you won't be able to skip path segments
$ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1///4 { "variables":"1/4//" }
hi @Sujith Mathew - can you provide a sample request URI so that we can help with policy
hmm, maybe this will help. Here's a working (loopback) API Proxy. Here you can see it working:
$ curl -i https://${ORG}-${ENV}.apigee.net/ev-uripath/ships/102903/sailDate/20180421 HTTP/1.1 200 OK Date: Mon, 12 Mar 2018 22:34:10 GMT Content-Type: application/json Content-Length: 52 Connection: keep-alive { "shipCode": "102903", "sailDate": "20180421" }
The policy config for this URI Path is:
<ExtractVariables name="EV-GetUriPathElements"> <DisplayName>Extract URI Variables</DisplayName> <URIPath name="proxy.url"> <Pattern ignoreCase="true">/ships/{shipCode}/sailDate/{sailDate}</Pattern> </URIPath> </ExtractVariables>
See attached for the working example proxy.
Thank you very much for timely response , howeever ;
$ curl -i https://${ORG}-${ENV}.apigee.net/ev-uripath/ships/102903/20180421 <br>
is my api and not
$ curl -i https://${ORG}-${ENV}.apigee.net/ev-uripath/ships/102903/sailDate/20180421 <br>
i tried your proxy and "ships/102903/sailDate/201804" comes in "proxy.pathsuffix" variable
Hope you understand my issue.
Please find the snapshot (from my on-premise installation version 4.16.01*) above.
All help to solve is appreciated.
@Dino/ Team
Can you please help to make sure shipcode also occurs for the below link
$ curl -i https://${ORG}-${ENV}.apigee.net/ev-uripath/ships/3933393/ui8y8yyyy
where 3933393 is shipcode and ui8y8yyyy is saildate
thank you
yes, you will need to change the pattern.
from this
<Pattern ignoreCase="true">/ships/{shipCode}/sailDate/{sailDate}</Pattern>
..to something that reflects your URI.
Presumably "shipCode" and "sailDate" are not the right things to collect meaningful information from your URI.
So change them, and eliminate or modify the fixed parts of that pattern, to fit your requirements.
If you are trying to get values for each variation, then you would need to provide patterns for each as well. I changed Dino's Extract Variables to use:
<URIPath> <Pattern ignoreCase="true">**/pay/{refnumber}</Pattern> <Pattern ignoreCase="true">**/pay/{refnumber}/{txnnumber}</Pattern> <Pattern ignoreCase="true">**/pay/{refnumber}/{txnnumber}/{sequencenumber}</Pattern> <Pattern ignoreCase="true">**/pay/{refnumber}/{txnnumber}/{sequencenumber}/{modeofpay}</Pattern> </URIPath>
Also changed the Assign Message good response to:
<Set> <Payload contentType="application/json">{ "variables":"{refnumber}/{txnnumber}/{sequencenumber}/{modeofpay}" } </Payload> <StatusCode>200</StatusCode> <ReasonPhrase>OK</ReasonPhrase> </Set>
Then all of these will populate appropriate values:
$ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1/2/3/4 { "variables":"1/2/3/4" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1/2/3 { "variables":"1/2/3/" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1/2 { "variables":"1/2//" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1 { "variables":"1///" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/foo/pay/1 { "variables":"1///" } $ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/foo/bar/pay/1 { "variables":"1///" }
But you won't be able to skip path segments
$ curl https://${ORG}-${ENV}.apigee.net/ev-uripath/pay/1///4 { "variables":"1/4//" }
working perfectly .
Thank you
Cheers !
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |