I would like to set a set of default query parameter name and value using javascript to my back end service,without adding them in the url everytime.
using javascript
@archana , You can use Assign Message Policy.
For Example,
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1"> <DisplayName>Assign Message-1</DisplayName> <Properties/> <Add> <QueryParams> <QueryParam name="q">nodejs</QueryParam> </QueryParams> </Add> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
Above appends request queryparam , ?q=nodejs to all the requests. See attached proxy & play with same here.
http://asagarnodeapp-test.apigee.net/googlebooks
googlebooks-rev1-2016-03-31.zip
Keep us posted if you see any issues while implementing same.
if i am doing something like this,adding the parameter when some condition is met ,what i have to add is only the parameter name ,the value is dynamic which i should get from developer or front end etc.How do i achieve that
<QueryParams> <QueryParam name="token"></QueryParam> </QueryParams> <Step> <Condition>(proxy.pathsuffix MatchesPath "/user-likes") and (request.verb = "GET)</Condition> <Name>Assign-1</Name> </Step>
@archana , Read about Apigee Flow Variables & Variables Reference, If it's dynamic value, you will use flow variables to add the value to queryparam.
<QueryParam name="token">{request.verb}</QueryParam>
I have added the parameters in assign message ,how to send them to the target url in JS which i rewrote accordingly.
User | Count |
---|---|
5 | |
2 | |
2 | |
1 | |
1 |