Bird
0
0

You want to send JSON data and receive XML response from a REST API. Which headers should you set?

hard📝 Application Q8 of 15
Rest API - Request and Response Format
You want to send JSON data and receive XML response from a REST API. Which headers should you set?
AContent-Type: application/json and Accept: application/xml
BContent-Type: application/xml and Accept: application/json
CAccept: application/json only
DContent-Type: text/plain and Accept: text/html
Step-by-Step Solution
Solution:
  1. Step 1: Identify header for request data format

    Content-Type must be 'application/json' to tell server you send JSON.
  2. Step 2: Identify header for desired response format

    Accept must be 'application/xml' to request XML response.
  3. Final Answer:

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

    Content-Type = sent data, Accept = desired response [OK]
Quick Trick: Content-Type = send format, Accept = receive format [OK]
Common Mistakes:
  • Swapping Content-Type and Accept values
  • Setting only one header
  • Using wrong media types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes