Salesforce

How to create a POST request using the OpenEdge HttpClient?

« Go Back

Information

 
TitleHow to create a POST request using the OpenEdge HttpClient?
URL NameHow-to-create-a-POST-request-using-the-OpenEdge-HttpClient
Article Number000122632
EnvironmentProduct: OpenEdge
Version: 11.5.1,11.6,11.7,12.x
OS: All Supported Platforms
Other: HttpClient
Question/Problem Description
The below code sample demonstrates a simple POST request using the HttpClient in the ABL.
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
BLOCK-LEVEL ON ERROR UNDO, THROW.

USING OpenEdge.Core.String.
USING OpenEdge.Net.HTTP.ClientBuilder.
USING OpenEdge.Net.HTTP.IHttpClient.
USING OpenEdge.Net.HTTP.IHttpRequest.
USING OpenEdge.Net.HTTP.RequestBuilder.
USING OpenEdge.Net.HTTP.IHttpResponse.
USING Progress.Json.ObjectModel.JsonObject.

/* ***************************  Definitions  ************************** */
DEFINE VARIABLE oClient   AS IHttpClient   NO-UNDO.
DEFINE VARIABLE oRequest  AS IHttpRequest  NO-UNDO.
DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO.
DEFINE VARIABLE oPayload  AS JsonObject    NO-UNDO.

/* ***************************  Main Block  *************************** */
oClient = ClientBuilder:Build():Client.

oPayload = NEW JsonObject().
oPayload:AddNumber('OrderNum','3213').
oPayload:AddNumber('ItemNum','432235').
oPayload:AddNumber('Qty','20000').

oRequest = RequestBuilder:Post('http://httpbin.org/post', oPayload)
                :Request.
oResponse = oClient:Execute(oRequest).

MESSAGE oResponse:StatusCode
    VIEW-AS ALERT-BOX.

CATCH oError AS Progress.Lang.Error :    
    MESSAGE oError:GetMessage(1) SKIP(2)
            oError:CallStack
        VIEW-AS ALERT-BOX.
END CATCH.
Workaround
Notes
References to Other Documentation:

Progress Article(s):
 OpenEdge.Net.pl is missing from PROPATH
 Is there an HTTP client for OpenEdge?
 
Keyword Phrase
Last Modified Date10/30/2023 1:05 PM

Powered by