Hi
I have to replace the actual target endpoint url using javascript policy.
I am having js file which takes the target url below
var targetUrl = context.getVariable("target.url");
But problem is that it doesn't include the resource name which is actually sent with Proxy Endpoint URL
Suppose, I have one API Proxy with many resources
API Proxy Endpoint - http://test.com:9002/legacy_api/v1/test
Target Endpoint - http://ip:8080/wfc/restcall/legacy_api/v1/test
Also I have resource name - RetrieveAllNames
When I hit the API Proxy on Gateway like below
http://test.com:9002/legacy_api/v1/test/RetrieveAllNames
Value of targetUrl = context.getVariable("target.url") gives only
http://ip:8080/wfc/restcall/legacy_api/v1/test not the whole
http://ip:8080/wfc/restcall/legacy_api/v1/test/RetrieveAllNames
So how to get the resource name also in the target.url in JS file
Thanks
Solved! Go to Solution.
You can use variable "request.querystring" to get query parameters and variable "proxy.pathsuffix" to get pathSuffix, and then concatenate the string to get complete URL (targetUrl+pathSuffix+queryString).
Even query parameters and path parameters are also lost with resource names when I take the variable
"target.url"
Is this variable "target.copy.pathsuffix" set to "false" ?
You can give below code to get the pathsuffix.
var pathSuffix = (context.getVariable("proxy.pathsuffix"))
You can use variable "request.querystring" to get query parameters and variable "proxy.pathsuffix" to get pathSuffix, and then concatenate the string to get complete URL (targetUrl+pathSuffix+queryString).
Is there a way to do get these query params, path params and resource names all in a Policy not using java script
May be some alternate to variable "target.url" which gives only the Target Endpoint
Hi @GAURAV,
Currently there is no single flow variable to get the complete URL. You have to use javascript to get the complete URL.
User | Count |
---|---|
7 | |
2 | |
2 | |
2 | |
1 |