Rest API Media Types
In this tutorial, we will learn about Rest API Media Types.
What is a Media Type?
A media type is a format of the data that is being transferred between the client and the server. It is also known as MIME type. It tells the client and the server about the structure of the data.
Note: Media Types are sent in the Content-Type header of the HTTP
request and response.
HTTP MediaTypes
Here is the list of common HTTP media types that we use in Rest API:MediaType | Description |
---|---|
application/json | Specifies the JSON format. It is used to transfer structured data between the client and the server. |
application/xml | Specifies the XML format. It is used to transfer structured data between the client and the server. |
application/x-www-form-urlencoded | Specifies the form data format. It is used to transfer form data between the client and the server. |
multipart/form-data | Specifies the form data format. It is used to transfer form data between the client and the server. |
text/plain | Specifies the plain text format. It is used to transfer text data between the client and the server. |
Here is the list of all HTTP MediaTypes that we mostly use in Rest API:
MediaType | Description |
---|---|
application/json | Specifies the JSON format. It is used to transfer structured data between the client and the server. |
application/xml | Specifies the XML format. It is used to transfer structured data between the client and the server. |
application/x-www-form-urlencoded | Specifies the form data format. It is used to transfer form data between the client and the server. |
multipart/form-data | Specifies the form data format. It is used to transfer form data between the client and the server. |
text/plain | Specifies the plain text format. It is used to transfer text data between the client and the server. |
application/javascript | Specifies the JavaScript format. It is used to transfer JavaScript code between the client and the server. |
application/octet-stream | Specifies the binary data format. It is used to transfer binary data between the client and the server. |
application/pdf | Specifies the PDF format. It is used to transfer PDF files between the client and the server. |
application/zip | Specifies the ZIP format. It is used to transfer ZIP files between the client and the server. |
image/jpeg | Specifies the JPEG format. It is used to transfer JPEG images between the client and the server. |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | Specifies the Excel format. It is used to transfer Excel files between the client and the server. |
multipart/mixed | Specifies the mixed content format. It is used to transfer multiple files of different types between the client and the server. |
multipart/encrypted | Specifies the encrypted content format. It is used to transfer encrypted files between the client and the server. |
application/vnd.api+json | Specifies the JSON API format. It is used to transfer JSON API data between the client and the server. |
If you have liked our content, please share it with your friends
and colleagues.
Rest API is wide and deep. We have
covered the concepts from basics to advanced
levels knowledge in this tutorial series. These are concepts
a tester should know to test the Rest
API.
If you are looking for interview questions on API Testing, then check out the Recommended
Links section.