Use HTTP headers and responses
When working with REST APIs, Semarchy xDI Designer can manipulate HTTP headers and parameters like any other data. You must add entries for all expected headers to your HTTP REST metadata.
Configure your metadata
From the Project Explorer, open an HTTP REST metadata object. Add an HTTP method if you do not have one already.
Depending on where in your flow you plan to work with the content, continue to the HTTP requests and HTTP responses section.
For HTTP requests
To send headers or parameters with an HTTP request, you must add it to the Operation node.
In the metadata editor, find an operation node to which you want to add parameters. If a Parameters node does not exist already, open the context menu on the operation node, and select New > Parameters to create it.
Open the context menu on the Parameters node, and select New > Parameter. An individual parameter node appears. Repeat this process for as many parameters as you need.
![howto request headers](../../_images/http-rest/howto-request-headers.webp)
Finally, set the parameter nodes' properties. Make sure to at least set a name, and a Location which tells xDI how to send it during processing. Possible values are:
-
cookie
-
header
-
path
-
query
For HTTP responses
To receive headers in an HTTP response, you must add it to a response with the appropriate response code.
In the metadata editor, find a response node where you want to add content. If a Responses node does not exist already, open the context menu on the operation node, and select New > Responses to create it.
Open the context menu on the Responses node, and select New > Response. A response node appears. Set its Code to the HTTP response code you plan to work with, or to default
to catch any unspecified codes. Define as many responses as you want.
For each response you need headers from, follow these steps:
-
Open the context menu on the appropriate response code node.
-
If it does not exist already, create a main headers node by selecting New > Headers.
-
Open the context menu on the Headers node, and select New > Header. An individual header node appears.
-
Create as many individual header nodes as you need.
-
Rename the individual header nodes to the expected name of the header.
![howto response headers](../../_images/http-rest/howto-response-headers.webp)
You can also handle HTTP response codes as data. Define their metadata entries as follows:
-
Open the context menu on the appropriate response code node.
-
If it does not exist already, create a main response information node by selecting New > Response Information.
-
Open the context menu on the Response Information node, and select New > ResponseInfo. An individual response information entry appears.
-
Select the ResponseInfo node, and set its Type parameter to one of three options:
protocolVersion
,reasonPhrase
, orstatusCode
. -
Create response information nodes for the other types as needed.
![howto response data](../../_images/http-rest/howto-response-data.webp)