Hi, What is the apigee variable to access the whole path including querystring?
Like this variable request.querystring only returns the query string in the URL request and proxy.pathsuffix variable retruns only path suffix. Like that I’m looking for a variable with will return the path and querystring. Please find the example as follows.
proxy.pathsuffix for this URL is /access_token (which is included in default.xml in proxy) and I wanted a variable to return abc/test?test=1 or /abc/test?test=1. I din’t find any variable to return this one.
Thanks @arghya das Tried this variable, it was giving the whole path without query string. It’s giving as “harmony/oauth2/access_token/abc/test”. I’m looking for the variable only which will return abc/test?test=1 or /abc/test?test=1.
@Swapna , Like @arghya das said, “message.uri” should work out of the box. It works for me in Apigee Cloud, Please see attached proxy & screenshot below.
There does not seem to be any variable documented here, that you can use to retrieve the specific part of the string from the request URL. You may have to write Javascript, etc code to do the same.
I tried out locally and it worked for me.
Here’s the snippet of the Javascript code:
// base path of the API
var basePath = context.getVariable("proxy.basepath");
// request path of the API including query string
var requestURI = context.getVariable("request.uri");
// Extract part of the string excluding base path
var myResourcePath = requestURI.substr(basePath.length+1);
context.setVariable("basePath", basePath);
context.setVariable("requestURI", requestURI);
context.setVariable("myResourcePath", myResourcePath);
This gave the output as shown below in my sample example:
If you use a simple javascript to remove the basepath from the messageURI variable, then you get the pathSuffix and the query params. Isn’t that what she wanted ?