tencent cloud

All product documents
Tencent Cloud Observability Platform
Last updated: 2025-03-11 19:41:12
Request
Last updated: 2025-03-11 19:41:12
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
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support