All Products
Search
Document Center

Performance Testing:Define a request body

Last Updated:Mar 11, 2026

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.

Note

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-TypeDescription
x-www-form-urlencodedName-value pairs (e.g., name=test&password=123456)
rawJSON, XML, plain text, HTML, or JavaScript strings
CustomCustom MIME types. Multipart, video, and image formats are not supported.

raw sub-types

When you select raw, specify a sub-type:

Sub-typeMIME typeDescription
Texttext/plainPlain text in TEXT, XML, or HTML format
JSONapplication/jsonJSON string
JavaScriptapplication/javascriptJavaScript string
XMLapplication/xmlXML string (media type: application/xml)
XMLtext/xmlXML string (media type: text/xml)
HTMLtext/htmlHTML string

Configure the request body

  1. On the API configuration page, click the Body Definition tab.

  2. Select a Content-Type: x-www-form-urlencoded, raw, or Custom.

  3. 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:

  1. In the upper-right corner of the Body Definition tab, click Decode Body.

  2. Select By UTF-8 or By GBK.

Body valueWithout decoding (incorrect)After decoding (correct)
%25PTS sends %2525PTS sends %25
name%3DtestPTS sends name%253DtestPTS 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:

KeyValue
nametest
password123456
Key-value pair format for x-www-form-urlencoded body

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
}
JSON body definition

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>
Text body definition