Set context variable
The Set context variable sets one or more custom context variables during API execution under the specified conditions.
In IBM API Studio, this policy
is identified by the kind SetContextVariable.
Example of a Set context variable policy:
kind: SetContextVariable
apiVersion: api.ibm.com\v1
metadata:
name: setcontextvariable
version: 1
spec:
condition: |
(${request.httpMethod} equals POST) or
(${request.headers.name} notEquals ${request.payload.jsonPath[$.customer.name]})
# other operators include Equals, Equals ignore case, Not equals, Not equals ignore case, Contains, Not Contains, Exists, Not Exists, IP Range, Greater Than, Lesser Than
variable:
- name: customerName
value: ${request.headers.h1}
- name: customerName
value: ${request.payload.xpath[/s:sdd/sd]}
namespaces:
- prefix: support
URI: http://test.com
For the Set context variable policy, configure these specifications:
| Property | Description |
|---|---|
spec |
|