200-901 Question 46
Single answerYou are developing an application that interacts with a REST API. While testing a POST request to create a new resource, the server responds with a 400 Bad Request error. The API documentation specifies that the 'Content-Type' header must be set to 'application/json', and the request body should include 'name' and 'description' fields. Upon reviewing your request, you notice that the 'Content-Type' header is set to 'text/plain'. What is the most likely cause of the error?
- A
The 'Content-Type' header in the request is incorrect.
- B
The API endpoint does not support POST requests.
- C
The server is experiencing an internal error.
- D
The request body is missing required fields.
Show answer and explanation
Correct answer: A
Explanation
A 400 Bad Request error typically means there is an issue with the client's request. In this scenario, the API documentation specifies a required 'Content-Type' header of 'application/json'. Since the request header incorrectly uses 'text/plain', the server rejects the request. Ensuring the correct 'Content-Type' resolves the issue.
- A. Correct.
Correct. The API documentation explicitly states that the 'Content-Type' header must be set to 'application/json', but the request uses 'text/plain', causing the 400 Bad Request error.
- B. Incorrect.
Incorrect. The error code 400 indicates a client-side issue, not that the POST method is unsupported by the API.
- C. Incorrect.
Incorrect. A 400 Bad Request error does not indicate a server-side issue like a 500 Internal Server Error would.
- D. Incorrect.
Incorrect. While missing fields could cause a 400 error, the question specifies that the issue lies with the 'Content-Type' header.