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:

DEFINE VARIABLE oURI AS URI NO-UNDO.
DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.

oURI = URI:Parse("http://oemobiledemo.progress.com/OEMobileDemoServices/rest/CustomerService/Customer?filter=CustNum=1").
oRequest = RequestBuilder:GET(oURI):Request.

To build requests that use other HTTP verbs, replace GET with the appropriate verb name, as shown in the following example.

oRequest = RequestBuilder:POST(oURI, oRequestBody):Request.
oRequest = RequestBuilder:PUT(oURI, oRequestBody):Request.
oRequest = RequestBuilder:DELETE(oURI):Request.
oRequest = RequestBuilder:HEAD(oURI):Request.
oRequest = RequestBuilder:OPTIONS(oURI):Request.
oRequest = RequestBuilder:TRACE(oURI):Request.

Another way to build an HTTP request is to use the Build() method, where you pass the HTTP verb as a parameter.

oRequest = RequestBuilder:Build('GET', oURI):Request.
oRequest = RequestBuilder:Build('POST', oURI):WithData(oRequestBody):Request.

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.
oRequest = RequestBuilder
			:GET(<URI>) 
				/* Other options include PUT | POST | DELETE | HEAD | PATCH | OPTIONS | TRACE */
			:AddHeader(<HttpHeader>)
            :HttpVersion("HTTP/1.1")
			:WithData(Progress.Lang.Object)
			:ContentType(<char>)
			:AuthCallback(<callback object> | <callback procedure>)
			:UsingBasicAuthentication(<Credentials>)
				/* Other options include UsingDigestAuthentication(<Credentials>) | UsingCredentials(<Credentials>) */
			:ViaProxy(<url>)
			:WithTransferEncoding(<encoding>)
			:Request.
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").

API reference documentation

To view the complete list of methods that you can use on an HTTP request object, refer to the RequestBuilder documentation or see the OpenEdge.Net API Reference documentation.