Getting started Community Training Tutorials Documentation APIs, AI & Tools
<apikit:config name="api-config"
api="api.raml"
outboundHeadersMapName="outboundHeaders"
httpStatusVarName="httpStatus"/>
Map APIkit for REST outbound headers and HTTP status values to variables the HTTP Listener writes into each response. Configure outboundHeadersMapName and httpStatusVarName on apikit:config so flows set vars.outboundHeaders and vars.httpStatus consistently across success and error paths. The steps align listener response blocks with those variable names.
You can configure the default variables that the HTTP listener searches for by configuring these properties in APIkit Router:
outboundHeadersMapName
Name of the variable that contains a headers map added in the response (outboundHeaders by default)
httpStatusVarName
Name of the variable that stores the status code to set in the response (httpStatus by default)
APIkit Router creates both variables and facilitates including custom HTTP headers and status codes in the response.
<apikit:config name="api-config"
api="api.raml"
outboundHeadersMapName="outboundHeaders"
httpStatusVarName="httpStatus"/>
To modify the default names of these variables, update the default HTTP listener configuration to align the variable names and the configuration.
<http:listener config-ref="api-httpListenerConfig" path="/api/*">
<http:response
statusCode="#[vars.httpStatus default 200]">
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
</http:response>
<http:error-response
statusCode="#[vars.httpStatus default 500]">
<http:body>#[payload]</http:body>
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
</http:error-response>
</http:listener>
Put the header to add in the outboundHeaders map, as shown in the following example:
<set-variable
value='#[vars.outboundHeaders default {} ++ {newHeaderName: "Header value"}]'
variableName="outboundHeaders"/>