What is Content-Type?
An HTTP header that specifies the format of the request or response body (e.g., JSON, XML, form data).
Definition
Content-Type is an HTTP header that indicates the media type of the request or response body. Common values include: "application/json" for JSON data, "application/x-www-form-urlencoded" for form data, "text/html" for HTML, and "text/plain" for plain text. The server uses this header to correctly parse the incoming data, and the client uses it to correctly display the response.
Simple Analogy
Like a file extension on your computer โ ".pdf" tells the system to open it with a PDF reader, ".jpg" with an image viewer. Content-Type tells the server how to interpret the data inside the request.
Why It Matters
A mismatched Content-Type causes parsing failures. If you send JSON but declare it as form data, the server will try to parse JSON as URL-encoded parameters and fail. CronJobPro lets you set the Content-Type header per job, ensuring your endpoint receives data in the format it expects.
How to Verify
Check your endpoint's documentation for accepted Content-Types. Verify the Content-Type header in CronJobPro's job configuration. In execution logs, confirm the request Content-Type matches what your endpoint expects. Test with curl: `curl -H "Content-Type: application/json" ...`.
Common Mistakes
Omitting Content-Type when sending a request body, leaving the server to guess. Using "text/plain" for JSON data. Not handling multiple Content-Types on the server side when clients may send different formats. Confusing Content-Type (what you are sending) with Accept (what you want back).
Best Practices
Always set Content-Type when including a request body. Use "application/json" for JSON payloads, which is the most common format for APIs. On your server, validate the Content-Type and return 415 Unsupported Media Type for unexpected formats.
HTTP Methods Guide
Learn about HTTP methods
Try it free โFrequently Asked Questions
What is Content-Type?
Content-Type is an HTTP header that indicates the media type of the request or response body. Common values include: "application/json" for JSON data, "application/x-www-form-urlencoded" for form data, "text/html" for HTML, and "text/plain" for plain text. The server uses this header to correctly parse the incoming data, and the client uses it to correctly display the response.
Why does Content-Type matter for cron jobs?
A mismatched Content-Type causes parsing failures. If you send JSON but declare it as form data, the server will try to parse JSON as URL-encoded parameters and fail. CronJobPro lets you set the Content-Type header per job, ensuring your endpoint receives data in the format it expects.
What are best practices for Content-Type?
Always set Content-Type when including a request body. Use "application/json" for JSON payloads, which is the most common format for APIs. On your server, validate the Content-Type and return 415 Unsupported Media Type for unexpected formats.
Related Terms
Request Header
Key-value metadata sent with an HTTP request to provide context like authentication and content type.
Request Body
The data payload sent with POST or PUT requests to provide input to the endpoint.
Response Body
The data payload returned by a server after processing an HTTP request.
HTTP Method
The verb (GET, POST, PUT, DELETE, etc.) that defines the type of action an HTTP request performs.