Handling non-JSON data in a REST API
REST APIs are set up by default to handle JSON data, but can also handle other data formats.
Before you begin
- You must create a REST API in the IBM® App Connect Enterprise Toolkit, see Creating a REST API.
- You must implement at least one operation in the REST API, see Implementing an operation in a REST API by using the REST API Editor for Swagger 2 documents.
About this task
When a message arrives on the Input node of a subflow for an implemented operation, the message domain of that message is set to JSON. You can handle other types of data in a subflow for an implemented operation by using a ResetContentDescriptor node to change the message domain of the message before any message parsing is performed.
You can also use a Route node to handle multiple types of data in the same subflow. You can configure the Route node to route data to a ResetContentDescriptor node based on the Content-Type header in the request message. The Content-Type header can be added to the request by the HTTP client, and is used to describe the type of the data in the request.
Procedure
To handle non-JSON data in a REST API, complete the following steps:
Results
What to do next
- Implement error handling for the REST API as a set of subflows, see Implementing an error handler in a REST API.
- Secure your REST API by using HTTPS for encrypting communications between the client and server, see Securing a REST API by using HTTPS.
- Secure your REST API by authenticating users with HTTP Basic Authentication, see Securing a REST API by using HTTP Basic Authentication.
- If your REST API is going to be used by client-side code that is running in a web browser, you might have to configure Cross-Origin Resource Sharing, see Permitting web browsers to access a REST API by using Cross-Origin Resource Sharing.