I have a proxy with base path "{host}/myapiTest/v1"
and I add a new api in this proxy with full path "{host}/myapiTest/v1/myapi/update/1234"
then I try to get the value 1234 with a block of code below in Extract Variable Policy
<URIPath>
<Pattern ignoreCase="true">/myapi/*/{id}</Pattern>
</URIPath>
After that, I print the {id} but the value is null.
So I try to change path of this api to "{host}/myapiTest/v1/apitest/update/1234" and finally I got the value of {id}.
I know that I can use the js code to get the {id} from "{host}/myapiTest/v1/myapi/update/1234" but I'm curious about this problem.
If anyone have the information, please tell me.
Thank you.
I am not sure if you can use a * within the Pattern. Even if you don't need that part of the URI, just extract it, and ignore it.
This works for me.
<ExtractVariables name="EV-GetUriPathElements-2">
<URIPath name="proxy.url">
<Pattern ignoreCase="true">/myapi/{action}/{id}</Pattern>
</URIPath>
</ExtractVariables>
Working Example
$ curl -i $endpoint/ev-uripath/myapi/update/1234
HTTP/1.1 200 OK
Date: Tue, 13 Jul 2021 00:41:32 GMT
Content-Type: application/json
Content-Length: 40
Connection: keep-alive
APIProxy: ev-uripath r1
{
"action": "update",
"id": "1234"
}
Please find the working proxy attached.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |