In this API example we will discuss what information a response can bear and how to define multiple responses. Technically a response is represented by a payload that is sent back in response to a request.
Group of all messages-related resources.
This action has two responses defined: One returning plain text and the
other a JSON representation of our resource. Both have the same HTTP status
code. Also both responses bear additional information in the form of a custom
HTTP header. Note that both responses have set the Content-Type
HTTP header
just by specifying (text/plain)
or (application/json)
in their respective
signatures.
Headers | |
---|---|
Content-Type | text/plain |
X-My-Message-Header | 42 |
text/plain
Hello World!
Headers | |
---|---|
Content-Type | application/json |
X-My-Message-Header | 42 |
application/json
{
"message": "Hello World!"
}
Headers | |
---|---|
Content-Type | text/plain |
text/plain
All your base are belong to us.