Construct a Request
This document introduces the construction method of Baidu AI Cloud REST API requests. All information provided in this document can be obtained from the API 3.0 documentation. You can also further learn how to construct an API request through the Video Guide.
Request URI
The structure of the request URI is as follows:
{Protocol}://{Endpoint}/{Request Path}?{Request Query}
| Parameters | Description | Examples |
|---|---|---|
| Protocol | The type of protocol used to transmit requests. Support both HTTP and HTTPS protocols, recommended to use HTTPS | HTTPS |
| Endpoint | Refer to the domain name or IP that provides cloud product API services. The endpoints of different products may vary. Please refer to BOS Endpoint | bj.bcebos.com |
| Request path | API access path, usually used to point to the path where the resource is located. | v2/instance |
| Request query | Query parameters, follow ? behind. Not every API has a request query; this needs to be determined based on the API documentation. | reboot |
For example, if you want to call the instance restart API of Baidu Cloud Compute (BCC), the request URI is as follows:

In specific API documentation, since the protocol and endpoint are relatively fixed, they are omitted for brevity, and the request method of the API is placed before the request path, as shown below:
Request message headers
Request message headers include commonly used configuration information, such as the data type, the time the call is made, and authentication details. Common request message headers applicable to all APIs are listed below.
| Name | Type | Description | Required or not |
|---|---|---|---|
| Authorization | String | Authentication information used to verify the validity of a request. For more details, see [Authentication](Reference/Authentication mechanism/Introduction.md) | Yes |
| Content-Length | String | The length of the HTTP request content as defined in RFC 2616 | No |
| Content-Type | String | The type of HTTP request content defined in RFC2616, usually application/json; charset=utf-8 | No |
| Content-MD5 | String | The MD5 summary of HTTP request content as defined in RFC 2616. It is used to verify the consistency between the file stored on BOS and the file expected by the user. | No |
| Date | String | The GMT time specified in the HTTP 1.1 protocol, such as Wed, 06 Apr 2016 06:34:40 GMT |
No |
| Host | String | The access host value, which is BucketName.bj.baidubce.com |
Yes |
| x-bce-date | String | Current time, following the ISO8601 standard, in the format of 2016-04-06T08:23:49Z |
No |
If an API has specific request message headers, they will be detailed in the API documentation.
Request message body
The structure of the request message body is determined by the Content-Type specified in the request headers. Usually, it needs to be in JSON format.
The content of the request message body varies for different APIs. Some APIs do not need a request message body, especially for GET or DELETE requests. For detailed requirements, please check the API documentation.
In the API documentation, the Description of Request Body Field Data Structure refers to the outermost field information of the json in the request message body. If the API has no request message body, this part of the content will be null.
If the request message body json contains nested data structures, they will be displayed under the table of Description of Request Body Field Data Structure using the Description of XXX Field Data Structure.

