Skip to content

Latest commit

 

History

History
233 lines (173 loc) · 7.15 KB

README.md

File metadata and controls

233 lines (173 loc) · 7.15 KB

Transform Query Parameters

Gravitee.io License Releases CircleCI

Overview

You can use the transform-queryparams policy to override incoming HTTP request query parameters.

You can override HTTP query parameters by:

  • Clearing all existing query parameters
  • Adding to or updating the list of query parameters
  • Removing query parameters individually

You can also append a value to an existing query parameter.

Query parameter values of the incoming request are accessible via the {#request.params['query_parameter_name']} construct.

Phases

The transform-queryparams policy can be applied to the following API types and flow phases.

Compatible API types

  • PROXY
  • MESSAGE
  • LLM PROXY

Supported flow phases:

  • Request

Compatibility matrix

Strikethrough text indicates that a version is deprecated.

Plugin version APIM Java version
2.x 4.8.x to latest 21
1.7.x 4.0.x to 4.7.x 17
1.6.x 3.x -

Configuration options

Name
json name
Type
constraint
Mandatory Default Description
Add or replace query parameter
addQueryParameters
array
See "Add or replace query parameter" section.
Clear all query parameters
clearAll
boolean Please be aware that by clearing all query parameters, you mustn't be able to use them in expression language.
Remove query parameters
removeQueryParameters
array (string)

Add or replace query parameter (Array)

Name
json name
Type
constraint
Mandatory Default Description
Append the value to existing queryParam as an array (i.e. ?key=v1&key=v2&key=v3) ?
appendToExistingArray
boolean
Name
name
string ✅
Value. (Supports EL)
value
string ✅

Examples

Add, update and remove query parameters

{
  "api": {
    "definitionVersion": "V4",
    "type": "PROXY",
    "name": "Transform Query Parameters example API",
    "flows": [
      {
        "name": "Common Flow",
        "enabled": true,
        "selectors": [
          {
            "type": "HTTP",
            "path": "/",
            "pathOperator": "STARTS_WITH"
          }
        ],
        "request": [
          {
            "name": "Transform Query Parameters",
            "enabled": true,
            "policy": "transform-queryparams",
            "configuration":
              {
                  "addQueryParameters": [
                      { "name": "added", "value": "addedValue" },
                      { "name": "toUpdate", "value": "updatedValue" }
                  ],
                  "removeQueryParameters": ["toRemove"]
              }
          }
        ]
      }
    ]
  }
}

Clear all and add a new query parameter

{
  "api": {
    "definitionVersion": "V4",
    "type": "PROXY",
    "name": "Transform Query Parameters example API",
    "flows": [
      {
        "name": "Common Flow",
        "enabled": true,
        "selectors": [
          {
            "type": "HTTP",
            "path": "/",
            "pathOperator": "STARTS_WITH"
          }
        ],
        "request": [
          {
            "name": "Transform Query Parameters",
            "enabled": true,
            "policy": "transform-queryparams",
            "configuration":
              {
                  "clearAll": true,
                  "addQueryParameters": [{ "name": "added", "value": "addedValue" }]
              }
          }
        ]
      }
    ]
  }
}

Append values to an existing query parameter

{
  "api": {
    "definitionVersion": "V4",
    "type": "PROXY",
    "name": "Transform Query Parameters example API",
    "flows": [
      {
        "name": "Common Flow",
        "enabled": true,
        "selectors": [
          {
            "type": "HTTP",
            "path": "/",
            "pathOperator": "STARTS_WITH"
          }
        ],
        "request": [
          {
            "name": "Transform Query Parameters",
            "enabled": true,
            "policy": "transform-queryparams",
            "configuration":
              {
                  "addQueryParameters": [
                      { "name": "appended", "value": "value1", "appendToExistingArray": true },
                      { "name": "appended", "value": "value2", "appendToExistingArray": true }
                  ]
              }
          }
        ]
      }
    ]
  }
}

Changelog

2.0.0 (2026-05-06)

chore
  • deps:: update gravitee-parent to v23.5.0 (530c5b4)
Features
  • enable the policy for LLM_PROXY APIs (8862a77)
BREAKING CHANGES
  • deps:: requires Java 21

1.9.0 (2023-12-19)

Features

1.8.0 (2023-12-01)

Features
  • add an option to handle array of values in a query parameter (253127b)

1.7.1 (2023-07-20)

Bug Fixes
  • update policy description (91bc7bd)

1.7.0 (2023-07-05)

Features
  • addition of the execution phase (9061fa3)