How to Log an HTTPRequest Object Created Using RequestBuilde

Posted by v205 on 25-Oct-2018 14:50

Greetings:

I am trying to capture the contents of the following oReq object to a LONGCHAR/CLOB etc. for logging purposes but having no luck. 

Does anyone know how to accomplish this? There are no other problems I am having with this logic. 

Here is how I am creating the oReq:

oReq = RequestBuilder:Build('GET', oUri)

:UsingBASicAuthentication(oCreds)

:AcceptJson()

:Request.

 I tried a CAST of oReq to a JsonObject and also to a String object with no luck (both returned an INVALID HANDLE). 

Thanks,

All Replies

Posted by Brian K. Maher on 25-Oct-2018 16:39

Use log-manager:logging-level = 5 in your code.  That will create the request and response text files in your working directory.  That should contain what you want.
 
 
Brian Maher
Principal Engineer, Technical Support
Progress
Progress
14 Oak Park | Bedford, MA 01730 | USA
phone
+1 781 280 3075
 
 
Twitter
Facebook
LinkedIn
Google+
 
 

Posted by v205 on 26-Oct-2018 08:08

Brian, I appreciate your response. Thank you for that.

However, I am trying to store the Request object 'oReq' in a LONGCHAR programmatically, instead of just logging it to a file on disk.

Anyone have any thoughts on how to do that?

Posted by Brian K. Maher on 26-Oct-2018 08:12

Check to see if it has a serialize method.
 
 
Brian Maher
Principal Engineer, Technical Support
Progress
Progress
14 Oak Park | Bedford, MA 01730 | USA
phone
+1 781 280 3075
 
 
Twitter
Facebook
LinkedIn
Google+
 
 

Posted by Matt Baker on 26-Oct-2018 08:21

You can't store a request object as a longchar.  it isn't a string, or at least it doesn't have a good representation as a string.  It is structured data (objects). The best you could do is convert it to a JSON document and turn that into a string, but you'd have to do that yourself. There isn't a utility to convert a request object to a string directly.  And you certainly can't simply cast it.

You'd have to write a data conversion method to convert the request into a string representation appropriate for whatever logging system you intend to use.

Posted by Peter Judge on 29-Oct-2018 08:30

The HttpRequest is currently not flagged as SERIALIZABLE .
 
Why do you want to save the request (persistently)?
 
We have a feature on our backlog to add better tracing (possibly using the semi-standard HAR format) for the HTTP client.
 
 

Posted by v205 on 29-Oct-2018 14:15

Hello, Peter. I am implementing a Request Tracker DB table that stores Request/Response as CLOB fields. For this, I need to be able to serialize the HTTPRequest object.

Posted by Peter Judge on 31-Oct-2018 10:33

For requests, you can follow the approach we use to serialize requests for passing to the server: github.com/.../ABLSocketLibrary.cls .

Note that the will put the request into a ByteBucket (basically a MEMPTR). I would store a BLOB and not a CLOB since there are likely to be cases where you have null bytes in the payload (images etc).

You'll have to write your own for responses (at the moment). The easiest way might be to add data recieved event to the socket, so that you'll get the data as it comes off the socket. This is untested though so YMMV.

This thread is closed