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
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
|
||||
Brian Maher
|
||||
Principal Engineer, Technical Support
|
||||
Progress
|
||||
14 Oak Park | Bedford, MA 01730 | USA
|
||||
|
||||
|
Hi Brian,
This is:
OpenEdge Release 11.6.3 as of Thu Sep 8 19:01:36 EDT 2016
Regards,
Steven
IF that's the data that is coming back, that should be being cast as a `JsonArray`, not a `JsonObject`. The [] indicates an array.
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