Showing empty JSON response (ABL HTTP client)

Posted by Steven Peeters on 16-Sep-2019 11:39

Hi,

OE 11.6.3

I'm trying to display a response using the ABL Http client.
The response (as I've been able to get in Postman) should be:

[
    {
        "data": [
            [
                "2019-09-16T07:23:58.060000",
                "None",
                "1900-01-01T00:08:45.250000"
            ],
            [
                "2019-09-16T07:33:04.620000",
                "X-ray",
                "1900-01-01T00:18:38.430000"
            ]
        ],
        "error": "",
        "statement_time": 0.70675600000000005,
        "total_time": 0.72309699999999999
    }
]

The code I'm using is:

oRequest = RequestBuilder:Get(vcUrl)
                         :AcceptJson()
                         :Request.
oResponse = ClientBuilder:Build():Client:Execute(oRequest).

oJsonEntity = cast(oResponse:Entity, JsonObject).
oJsonEntity:Write(JsonString, true).
message string(JsonString)
view-as alert-box.

I'm getting an empty result. just "{}".
Response-data-received.txt (LOGMANAGER output) is showing the correct json response.

I've tried this code on an OE Dataobject and this code displayed the JSON just fine.

What am I doing wrong here?

Regards,

Steven

All Replies

Posted by Steven Peeters on 16-Sep-2019 11:59

This is the output of response-data-received.txt:

HTTP/1.0 200

Cache-Control: no-cache, must-revalidate, no-store, post-check=0, pre-check=0

Expires: Thu, 01 Jan 1970 00:00:00 GMT

Content-Type: application/json

[ { "data": [ [ "2019-09-16T07:23:58.060000","None","1900-01-01T00:08:45.250000" ],[ "2019-09-16....

I notice there is no content-length and HTTP is 1.0 (not like 1.1 for the response I got for the OE dataobject).

Could this be the cause?

Regards,

Steven

Posted by Brian K. Maher on 16-Sep-2019 12:08

Hi Steven,
 
Can you post the contents of your $DLC/version file?
 
Brian Maher
Principal Engineer, Technical Support
Progress
Progress
14 Oak Park | Bedford, MA 01730 | USA
phone
781-280-3075
Twitter
Facebook
LinkedIn
Google+
 

Posted by Steven Peeters on 16-Sep-2019 12:25

Hi Brian,

This is:

OpenEdge Release 11.6.3 as of Thu Sep  8 19:01:36 EDT 2016

Regards,

Steven

Posted by danielb on 17-Sep-2019 02:48

IF that's the data that is coming back, that should be being cast as a `JsonArray`, not a `JsonObject`. The [] indicates an array.

Posted by Steven Peeters on 17-Sep-2019 05:44

oJsonArray = cast(oResponse:Entity, JsonArray). 
oJsonArray:Write(JsonString, true).

The code above will show error 12869, invalid cast from JsonObject to JsonArray.

COPY-LOB FILE "c:\temp\test.json" TO JsonString CONVERT TARGET CODEPAGE "UTF-8".
oParser = NEW ObjectModelParser().
oJsonArray = CAST(oParser:Parse(JsonString), JsonArray).  
oJsonArray:Write(JsonString, true).
message string(JsonString)
view-as alert-box.

The code above does work however.

We also found KB 93379 "HTTP Client does not return a response body". This resembles our situation. (even though the environment in the KB states 11.7.x)
As we're not going to upgrade from 11.6.3 in the near future and we can't force the server to send the content-lenght header, we'll just use the classic socket approach.

Regards,

Steven

This thread is closed