To stress-test APIs that accept input data, define a request body that simulates real traffic. Select a Content-Type that matches what your API expects -- x-www-form-urlencoded, raw, or Custom -- and enter the body content in the corresponding format.
Body definition is available only for POST, PUT, and PATCH requests.
Prerequisites
Before you begin, configure basic request information for the HTTP API. See Basic request information.
Content-Type options
Select the Content-Type based on the data your API expects:
| Content-Type | Description |
|---|---|
| x-www-form-urlencoded | Name-value pairs (e.g., name=test&password=123456) |
| raw | JSON, XML, plain text, HTML, or JavaScript strings |
| Custom | Custom MIME types. Multipart, video, and image formats are not supported. |
raw sub-types
When you select raw, specify a sub-type:
| Sub-type | MIME type | Description |
|---|---|---|
| Text | text/plain | Plain text in TEXT, XML, or HTML format |
| JSON | application/json | JSON string |
| JavaScript | application/javascript | JavaScript string |
| XML | application/xml | XML string (media type: application/xml) |
| XML | text/xml | XML string (media type: text/xml) |
| HTML | text/html | HTML string |
Configure the request body
On the API configuration page, click the Body Definition tab.
Select a Content-Type: x-www-form-urlencoded, raw, or Custom.
Enter the body content in the format that matches your selected Content-Type. See the examples below.
Avoid double-encoding with x-www-form-urlencoded
When you select x-www-form-urlencoded, PTS automatically URL-encodes the body before sending. If your body already contains encoded values, PTS re-encodes them, which corrupts the request.
For example, the percent sign % is encoded as %25. If you enter %25 directly, PTS re-encodes it to %2525.
To fix this, decode the body before running the stress test:
In the upper-right corner of the Body Definition tab, click Decode Body.
Select By UTF-8 or By GBK.
| Body value | Without decoding (incorrect) | After decoding (correct) |
|---|---|---|
%25 | PTS sends %2525 | PTS sends %25 |
name%3Dtest | PTS sends name%253Dtest | PTS sends name%3Dtest |
Examples
The following examples use a book system with a login endpoint that accepts an initial account (name=test, password=123456).
x-www-form-urlencoded
Enter the body as key-value pairs in the Body Definition tab:
| Key | Value |
|---|---|
| name | test |
| password | 123456 |

To switch to text format, click Text Format in the upper-right corner of the Body Definition tab. The text format supports up to 65,535 characters. Example:
{"name":"test","password":"123456"}JSON (application/json)
Select raw > JSON, then enter a JSON string:
{
"code": 200,
"data": {
"items": [
{"id": "123", "name": "yaozhuang"},
{"id": "456", "name": "fuzhuang"}
]
},
"requestId": "Cf2HJKEf-197B-JK47-79E9-FA*****4KA40",
"successResponse": false
}
Text (text/plain)
Select raw > Text, then enter plain text. This example sends an XML payload as plain text:
<?xml version="1.0"?>
<resource>
<id>123</id>
<params>
<name>
<value>test</value>
</name>
</params>
</resource>