tencent cloud

Performance Testing Service

Overview
Purchase Guide
Billing Overview
Pay-as-You-Go (postpaid)
Purchasing Channels
Payment Overdue
Refund Instructions
Quick Start
Operation Guide
Performance Testing in Simple Mode
Performance Testing in Script Mode
Performance Testing in JMeter Mode
Project Management
Scenario Management
Traffic Recording
Environment Management
Scheduled Performance Testing
Performance Testing Report
Access Control
Alarm Management
Tag Management
Error Code Manual
Practice Tutorial
Using Prometheus To Monitor Performance Testing Metrics
Using PTS to Playback Requests Recorded by GoReplay
API Documentation
History
Introduction
API Category
Making API Requests
PTS-related APIs
Data Types
Error Codes
JavaScript API List
Overview of JavaScript API List
pts/global
pts/http
pts
pts/dataset
pts/grpc
pts/jsonpath
pts/protobuf
pts/redis
pts/sql
pts/url
pts/util
pts/ws
pts/socketio
pts/socket
FAQs
Related Agreements
Service Level Agreement
Use Limits
Privacy Policy
Data Processing And Security Agreement

Request

PDF
Focus Mode
Font Size
Last updated: 2025-03-10 17:04:49
Request is the request structure when initiating a request.

Field

Field
Type
Description
basicAuth?
BasicAuth
Basic authentication.
body?
string, object, or ArrayBuffer.
The request body to be sent, which only needs to be specified when using the http.do method.
chunked?
function,(body string) => void
When data is sent in a series of chunks, if the chunked function is specified, the response body will be read line by line and the callback function will be executed.
contentLength?
number
Record the length of the associated content; -1 indicates unknown length, >=0 indicates the number of bytes that can be read from the body.
discardResponseBody?
boolean
Discard the response body, suitable for scenarios where the response body is too large and the response body content does not need to be checked.
headers?
Record<string, string>
Request header.
host?
string
host or host:port.
maxRedirects?
number
The maximum number of redirects.
method?
string
Specify the HTTP method, such as GET, PUT, and POST. It only needs to be specified when using the http.do method.
path?
string
The path; leading slashes are omitted for relative paths.
query?
Record<string, string>
URL parameters sent with the request.
scheme?
"http" | "https"
Protocol, "http" or "https" should be filled in.
service?
string
In PTS, different services are identified based on the URL, and reports are generated based on this dimension. For example, when the URL is http://demo.com/{id}, different IDs will be recognized as different services. By specifying the service, such requests can be categorized under the same service in the report.
timeout?
number
The time limit for requests issued by the client, where the timeout period in milliseconds includes connection time, any redirects, and reading the response body.
url?
string
The URL to be accessed, which only needs to be specified when using the do method.

Samples

Use Request in the http.do method:
import http from 'pts/http';

export default function () {
const req = {
method: 'post',
url: 'http://httpbin.org/post',
headers: { 'Content-Type': 'application/json' },
query: { a: '1' },
body: { user_id: '12345' },
};
const resp = http.do(req);
console.log(resp.json().args.a); // 1
console.log(resp.json().json.user_id); // 12345
}


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback