Receiving a uncomplete JSON file
Hi Guys,
I'm using the below code but I'm getting an uncomplete JSON file, so it seems that the command S obj=Httprequest.HttpResponse.Data.Read(Httprequest.HttpResponse.Data.Size) is not reading the whole file, so maybe the file is too big so is there a max size or can I change something in my call ?
The uncomplete file that I received so far is about 3.5MB
set Httprequest = ##class(%Net.HttpRequest).%New()
Set Httprequest.SSLConfiguration="RTLS"
Set Httprequest.Server="vibra-api-prod.azurewebsites.net"
Set Httprequest.Https=1
Set Httprequest.Timeout=30
set Httprequest.ContentType="application/json"
Do Httprequest.SetHeader("Accept","*/*")
Do Httprequest.SetHeader("Accept-Language","en_US")
Do Httprequest.SetHeader("Authorization","Bearer "_Token)
set tSc = Httprequest.Post("/api/jobs")
S StatusCode=Httprequest.HttpResponse.StatusCode
S obj=Httprequest.HttpResponse.Data.Read(Httprequest.HttpResponse.Data.Size)
Thanks
Last line:
S obj={}.%FromJSON(Httprequest.HttpResponse.Data)
it doesn't compile, FYI I'm running Ensemble 2014
Oh, right. You're on Ensemble 2014.1. I highly recommend updating to the latest Ensemble version or even better migrating to InterSystems IRIS.
Back of the napkin here, but I'm guessing that Eduard's dynamic object implementation wasn't available in 2014. 3.5mb seems suspicious as a string size limit so I would suggest trying to read the data into a stream explicitly. ex. from the latest IRIS documentation which I believe may still be pertinent to your use case.
Accessing the HTTP Response
set request=##class(%Net.HttpRequest).%New() set request.Server="tools.ietf.org" set request.Https=1 set request.SSLConfiguration="TEST" set status=request.Get("/html/rfc7158") if $$$ISERR(status) { do $system.OBJ.DisplayError() } else { set response=request.HttpResponse } Set file=##class(%FileCharacterStream).%New() set file.Filename="c:/temp/rfc7158.html" set status=file.CopyFrom(response.Data) if $$$ISERR(status) { do $system.OBJ.DisplayError() } do file.%Close()