Setting query-string parameters for a target API call

Assume your ION API Gateway endpoint usually is going to call this target API: https://myserver/path?p1=v1&p2=v2

The query-string parameters can be adjusted using a special transformation helper called {SetReqQuery}. For example, if you want to add an additional parameter of p3=v3 to the target API call, you would add the following to your transformation: SetReqQuery 'p3' 'v3'

This causes the gateway to call the target using the following URL: https://myserver/path?p1=v1&p2=v2&p3=v3

Adding a query parameter with a constant value can also be done using the QueryParam policy. Adding a query parameter using a transformation comes from accessing the value from anywhere in the POST body or from any of several useful "request context" variables.

You can take a value from a POST payload and turn it into a query-parameter. For example, if our endpoint takes a POST JSON payload of the form:

Example

{   "customer": "Acme",   "creditLimit": 50000 }

You can use the following helper to add the creditLimit to the query-string:

Example

SetReqQuery 'cl' (jsonPathValue '$.creditLimit')

You can also take the value of a request header and pass it to the target as a query-parameter if your request includes a header called 'some-data' with a value of abc123.

We can send this to the target as a query-param called 'data' using this helper:

Example

SetReqQuery 'data' (requestVars 'request.header.some-data')

The gateway would call the target server using this URL: https://myserver/path?p1=v1&p2=v2&data=abc123