Bird
0
0

You want to send JSON data to an API and receive a JSON response. Which headers should you set correctly in your HTTP request to ensure this communication?

hard📝 Application Q15 of 15
Rest API - Request and Response Format
You want to send JSON data to an API and receive a JSON response. Which headers should you set correctly in your HTTP request to ensure this communication?
AContent-Type: application/json and Accept: application/json
BContent-Type: text/plain and Accept: application/json
CContent-Type: application/json and Accept: text/html
DContent-Type: application/xml and Accept: application/json
Step-by-Step Solution
Solution:
  1. Step 1: Set Content-Type for request data

    Since you are sending JSON data, set Content-Type: application/json so the server knows the format of the data you send.
  2. Step 2: Set Accept for response format

    To receive JSON response, set Accept: application/json to tell the server you want JSON back.
  3. Final Answer:

    Content-Type: application/json and Accept: application/json -> Option A
  4. Quick Check:

    Both headers set to application/json for JSON exchange [OK]
Quick Trick: Both headers must match JSON for send and receive [OK]
Common Mistakes:
MISTAKES
  • Setting Content-Type and Accept to different formats
  • Using text/plain or XML when JSON is needed
  • Forgetting to set Accept header

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes