Build an HTTP request
- Last Updated: March 19, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Parts of an HTTP request message
An HTTP request message consists of the following parts:
- A request line, which specifies an HTTP method (GET, PUT, POST, DELETE, etc), a URI to a resource on the server, and the HTTP protocol version.
- A set of headers that provide various kinds of information to
the server. Each header is a name-value pair. For example,
Content-Type: text/plain. - A blank line that separates the header section from the request body.
- A request body that consists of the payload or data that is to be sent to the server.
Create an HTTP request object
To construct an HTTP request message, create a request object in
your ABL program using the OpenEdge.Net.HTTP.RequestBuilder class, which implements the IHttpRequest interface. At minimum, you need a URI and an HTTP verb. You can
optionally add a request body and headers.
The following example builds a request with the HTTP GET
verb:
|
To build requests that use other HTTP verbs, replace GET with the appropriate verb name, as shown in the following example.
|
Another way to build an HTTP request is to use the Build() method, where you pass the HTTP verb as a
parameter.
|
Based on your requirements, you may also need to perform the following tasks:
Other HTTP request methods
RequestBuilder is a fluent interface that enables you to
invoke multiple methods in a method chain. The RequestBuilder:GET | PUT | POST | ..():Request is the minimum required to
build an HTTP request. Here are a few other methods that you can add in the method
chain.
|
Note: Currently, the
OpenEdge.Net library supports only HTTP 1.1, so if you need to use the
HttpVersion() method, you should pass the
string "HTTP/1.1"—HttpVersion("HTTP/1.1").