HTTP messages and content types
To work with REST messages and content in Semarchy xDI Designer, you must add entries for all expected content to your HTTP REST metadata.
Configure your metadata
From the Project Explorer, open an HTTP REST metadata object. Add an HTTP method if you don’t 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 a message with an HTTP request, you must add it to a request body.
In the metadata editor, find an operation node to which you want to add content. If a Request Body node does not exist already, open the context menu on the operation node, and select New > Request Body to create it.
Open the context menu on the Request Body node, and select New > Content. A content node appears.
Select the new content node to open its properties. Set the Media Type and the Content-Type header according to the needs of your server.
![howto content request](../../_images/http-rest/howto-content-request.webp)
To create multipart requests, see Multipart data. |
For HTTP responses
To receive a message in an HTTP response, you must add it to a response with the appropriate response code.
In the metadata editor, find an operation 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 plan to work with, open the context menu on the Request Body node, and select New > Content. A content node appears.
Select the new content node to open its properties. Set the Media Type and the Content-Type header according to the needs of your server.
![howto content response](../../_images/http-rest/howto-content-response.webp)
Content types
Media type
Semarchy xDI handles five media types for HTTP messages:
-
BINARY
-
FORM
-
JSON
-
TEXT
-
XML
Select the appropriate type based on your content.
Content-Type header
You can also choose the Content-Type header that xDI sends to the web server. The following headers are available by default:
-
application/json
-
application/octet-stream
-
application/xml
-
application/x-www-form-urlencoded
-
text/csv
-
text/plain
To use a different header, type it manually in the field.