Constructing Requests
A request consists of three parts: a request line, request header, and request body (optional).
Request Line
A request line consists of three parts in order, separated by spaces: a method token, a request URI, and a protocol version. The format is shown in the following code:
Method Request-URI HTTP-Version CRLF
- Method: indicates a request method. All methods are capitalized. Their meanings are as follows:
- GET: obtains the resource identified by a Request-URI.
- POST: suffixes new data to the resource identified by a Request-URI.
- PUT: requests a server to store a resource and uses a Request-URI to identify the resource.
- DELETE: requests the server to delete the resource identified by a Request-URI.
- PATCH: requests a server to update a resource or create a resource if the target resource does not exist.
- Request-URI: indicates a unified resource identifier.
Enter a question mark (?) and an ampersand (&) at the end of the URI to define multiple search criteria. The content contained in {} in the URI is the parameter of the URI, where ? is contained. The previous part is the path parameter, and the latter part is the query parameter.
- HTTP-Version: indicates the version of the HTTP protocol used by a request.
- CRLF: indicates the carriage return and line feed characters. CRLF is placed only at the end of a line, and a separate CR or LF is not allowed.
Request Header
A request header consists of several header fields. Each header field consists of a domain name, a colon (:), and a field value.
Common request headers are listed in Table 1.
Request Body
A request message body is a JSON-style nested key-value pair. The mandatory and optional fields of an HTTP request body vary depending on the URI.
Last Article: Token-based Authentication
Next Article: Initiating Requests
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.