REST APIs Request and Response
Let’s learn to use JSON/XML in the request and response of the REST APIs.
We'll cover the following...
We'll cover the following...
REST API Request
The Content-Type header
We’ve seen a few POST and PUT requests to the REST API endpoints with the JSON request body.
For example, look at the already discussed POST request to create the TodoType object.
curl --location --request POST 'http://localhost:8080/api/todoType/' \--header 'Content-Type: application/json' \--data '{"code": "PERSONAL","description": "Todo for Personal Work"}'
In this request, the value of the Content-Type header is application/json. So, the application looks for the data in the request body and deserializes it considering JSON.
Similarly, we can set the Content-type header as application/xml for ...