Hi,
I have a requirement to pass dynamic value in url as host/basePath/operationName/AccountNumber?applicationId=a&SourceSystem=b , where AccountNumber will always vary.
We have to add new operation in existing api proxy.
I have added a new conditional flow
<Flow name="operationName">
<Description/>
<Request/>
<Response/>
<Condition>(proxy.pathsuffix MatchesPath "/*/operationNaame/{AccountNumber}") and (request.verb = "GET")</Condition>
</Flow>
and using extract variable policy
<Pattern ignoreCase="true">/operationName/{AccountNumber}/</Pattern>
and have used javascript
var host = context.getVariable('host-name');
var opName = context.getVariable('operationName');
var query= context.getVariable('request.querystring');
var accNumber= context.getVariable('apigee.AccountNumber'); if(opName.includes("operationName"))
{ opName="operationName/{}"; resourcePath="/basepath/"; }
else{ resourcePath="existed basepath of previous operation/"; }
var targeturl = "https://"+host+resourcePath+opName+"?"+query;
context.setVariable("target.url", targeturl);
I am getting response but data is not reflecting that means getting null value.
please help me out.
It is happening may be because, you have get the variables but have not set it yet.
Please try below code:
var host = context.getVariable('host-name');
context.setVariable("host",host);
var opName = context.getVariable('operationName');
context.setVariable("opName",opName);
Also make sure host-name and operationName have some values.