Raw body lets you send exact text or XML data in your API requests. This helps test how the server handles specific input formats.
Raw body (text, XML) in Postman
POST /api/example HTTP/1.1
Host: example.com
Content-Type: text/plain
Your raw text data hereSet the Content-Type header to match your raw data type (e.g., text/plain or application/xml).
In Postman, select 'raw' in the Body tab and choose the data format from the dropdown.
POST /api/message HTTP/1.1 Host: example.com Content-Type: text/plain Hello, this is a plain text message.
POST /api/xml HTTP/1.1
Host: example.com
Content-Type: application/xml
<note><to>User</to><message>Hello XML</message></note>This request sends an XML order to the server. The server should parse the XML and respond accordingly.
POST /api/submit HTTP/1.1 Host: example.com Content-Type: application/xml <order><id>123</id><item>Book</item></order>
Always match the Content-Type header with the raw data format you send.
Raw body is useful when APIs do not accept JSON or form data.
Use Postman's preview or response tabs to verify the server's reply.
Raw body lets you send exact text or XML in API requests.
Set the correct Content-Type header to help the server understand your data.
Use raw body to test APIs that expect plain text or XML inputs.
Practice
Raw body option in Postman when testing APIs?Solution
Step 1: Understand Raw Body usage
The Raw body option allows sending exact text or XML data in the request body without modification.Step 2: Compare with other options
Other options like form-data or JSON editor do not send plain text or XML exactly as typed.Final Answer:
To send exact text or XML data as the request body -> Option AQuick Check:
Raw body = exact text/XML data [OK]
- Confusing raw body with JSON auto-formatting
- Thinking raw body generates data automatically
- Using raw body to validate response codes
Solution
Step 1: Identify correct Content-Type for XML
XML data requires the Content-Type header to beapplication/xmlso the server knows to parse XML.Step 2: Eliminate other options
application/jsonis for JSON,text/plainis plain text, andmultipart/form-datais for file uploads.Final Answer:
application/xml -> Option DQuick Check:
XML Content-Type = application/xml [OK]
- Using application/json for XML data
- Omitting Content-Type header
- Choosing text/plain for XML
<note> <to>Alice</to> <from>Bob</from> <message>Hello</message> </note>
What will the server receive if the Content-Type is correctly set to
application/xml?Solution
Step 1: Understand raw body with XML and Content-Type
When raw XML is sent with Content-Typeapplication/xml, the server receives the exact XML text including tags.Step 2: Eliminate other options
The server does not convert XML to JSON automatically, nor strip tags or throw errors if XML is supported.Final Answer:
The exact XML text as shown, including tags and content -> Option CQuick Check:
Raw XML + application/xml = exact XML text [OK]
- Assuming XML converts to JSON automatically
- Thinking tags are removed in transmission
- Believing server errors without checking support
<user> <name>John</name> <age>30</age> </user>
But the server returns a 400 Bad Request error. What is the most likely cause?
Solution
Step 1: Check XML validity
The XML tags are well-formed and valid, so the XML itself is not the issue.Step 2: Consider Content-Type header
If the Content-Type header is missing or not set toapplication/xml, the server may reject the request with 400 error.Final Answer:
Content-Type header is missing or incorrect -> Option BQuick Check:
Missing/incorrect Content-Type causes 400 error [OK]
- Blaming XML syntax without checking header
- Thinking raw body cannot send XML
- Assuming Postman lacks raw body support
START successfully?Solution
Step 1: Identify data type expected by API
The API expects plain text commands, so raw body should contain plain text likeSTART.Step 2: Set matching Content-Type header
For plain text, the Content-Type must betext/plainto inform the server correctly.Final Answer:
Set raw body to START and Content-Type to text/plain -> Option AQuick Check:
Plain text command needs text/plain header [OK]
- Sending plain text with JSON or XML headers
- Wrapping plain text in JSON or XML tags unnecessarily
- Using wrong Content-Type for plain text
Ready to prove it?
Pass the test and this pattern moves unknown
