OpenEdge.Net.HTTP.IHttpRequest
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
All requests have two mandatory elements: an HTTP verb method (GET, for example) and a URI (the address for the request).
Some requests also require a payload (also called the entity, body, or message). To
add a payload to a request, set the Entity property to an object
instance. All entity data must be held in an object instance. Headers can be added
to the request by adding the SetHeader() method.
Request objects can be used by multiple requests.
Building a request
The OpenEdge.Net.Http.RequestBuilder helper class provides a fluent
(or chained) API for creating IHttpRequest objects.
The initial methods to call are one of the following static HTTP verb methods:
RequestBuilder:Get ( uri [, entity ])RequestBuilder:Put ( uri, entity )RequestBuilder:Post ( uri, entity )RequestBuilder:Delete ( uri [, entity ])RequestBuilder:Head ( uri )RequestBuilder:Options ( uri [, entity ])RequestBuilder:Trace ( uri )
Where uri is either an instance of a URI object
or a character string, and entity is an instance
of an object.
After an initial method is called, a number of additional methods can be chained, including:
AddHeader(): Add custom headers.-
Accept*: Methods to add media types to the Accept header. HttpVersion: Change the HTTP version from its 1.1 default.AddJson( entity ),AddFormData( data ),WithData( entity ), andWithData( entity, content type ): Add JSON, Form or other data to the request.UsingBasicAuthentication,UsingDigestAuthentication, andUsingCredentials: Add credentials to the request.Note:The more general
UsingCredentialsdoes not resolve a challenge. See https://tools.ietf.org/html/rfc2617 for information about challenges.Also note that credentials are only retrieved when the request is being executed.
AuthCallback: Add a listener to authentication events from a request.ContentType: Indicates the content type of the entity being sent with a request.
Once the request is built, it must be returned by calling the Request property. It
can then be passed into the HTTPClient for execution.
Examples
The following code samples contain examples of using
RequestBuilder.
Basic Get
|
Simple PUT
|
Adding Basic Authentication
|
Adding general credentials
|
Adding Auth Filter Callback as a class
|
Adding Auth Filter Callback as a procedure
|