Using http RequestBuilder:Post in 11.5.1

Posted by dianne.evans@danwood.co.uk on 02-Nov-2015 06:57

Environment:  Linux,  Openedge 11.5.1

I'm trying my first trials with IHttpRequest, but I am very new to using classes in Openedge.

Working through the examples in the 11.5.1 release-notes (and/or the previous white paper) I want to POST some data to a particular site. 

However the examples jump from simple GET/PUT, straight to the Responses, and miss out Post.

My code contains:

   oRequest = RequestBuilder
                    :Post(ip-uri, oReq-entity)                   
                    :AcceptAll()
                    :ContentType ("application/x-www-form-urlencoded")
                    :Request
                    no-error.

where ip-uir is my site, and oReq-entity is defined as

define variable oReq-Entity as CLASS Progress.Lang.Object               no-undo

.

My first, novice, question is:
how do I get any kind of value into the Object to pass as the Post parameter.
Could someone give me a short example of Posting a simple character-string?

Eventually I will want to post a memptr, that is mainly XML, that itself came from a temp-table,  
but for now I just want to post anything, such as a hard-coded string.

Many thanks


 

All Replies

Posted by dianne.evans@danwood.co.uk on 03-Nov-2015 08:28

Thank you for this - I have managed to get a fair bit further.

My next challenge is on the Response side of things.

I have a response object as:

  oRequest = RequestBuilder:Get(ip-uri)
                    :AcceptAll()
                    :Request

and then I can pull out the following Properties, which all look good:

MESSAGE 'Status: Code/Reason' oResponse:StatusCode oResponse:StatusReason SKIP 'Version:' oResponse:Version SKIP 'Character Encoding:' oResponse:CharacterEncoding SKIP 'Transfer Encoding:' oResponse:TransferEncoding SKIP 'Content Type:' oResponse:ContentType SKIP 'Content Length:' oResponse:ContentLength SKIP 'MD5' STRING(oResponse:ContentMD5) skip view-as alert-box title "oReponse details".

However, I seem to be having problems when trying to access the methods for
GetHeader and/or GetHeaders.

I have tried putting

USING  OpenEdge.Net.HTTP.HttpHeader.at the top, but that is not understood at all, so I'm unable to define a variable as a HttpHeader (or as an array of)

Is oResponse:GetHeaders available to me in 11.5.1

The best documentation I have found is:

https://documentation.progress.com/output/oehttpclient/index.html?OpenEdge.Net.HTTP.DefaultRequestBuilder.html

 

If possible, could someone provide a snippet of code to obtain the headers from the HttpResponse object?

 

Many thanks again

 

Posted by dianne.evans@danwood.co.uk on 03-Nov-2015 09:13

Ha, I grasped it (a bit), after posting the above.

define variable oHeader      as class OpenEdge.Net.HTTP.HttpHeader         NO-UNDO.

define variable oHeaderArray as class OpenEdge.Net.HTTP.HttpHeader extent   NO-UNDO.

define variable iHeaderCount as       integer                           no-undo.

then

  oHeader = oResponse:GetHeader("known-header-name").

  or            

  iHeaderCount = oResponse:GetHeaders(oHeaderArray).

and then

do i-loop = 1 to iHeadercount:

               MESSAGE

                 "loop header" i-loop    SKIP

                 ""   oHeaderArray[i-loop]:Name   SKIP

                 ""   oHeaderArray[i-loop]:Value     SKIP

                 VIEW-AS ALERT-BOX TITLE "debug".

               end.                    

So now just the body to deal with...

This thread is closed