Page 1 of 1

Web API - XPRIM_RandomAccessJsonReader - Size Limit?

Posted: Tue Sep 06, 2022 1:06 am
by Joerg Hamacher
Hi,

I use XPRIM_RandomAccessJsonReader for working with HTTP request responses.

Definition: Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Reader)
Receiving the HTTP response: #Reader.SetSourceString String(#HTTP_Request.Response.AsString) Errorinfo(#ErrorInfo)

I have to work with responses that are quite large - CurSizes of #HTTP_Request.Response.AsString can be more than 200000.
I have the feeling that the Reader cannot save so many characters. Is this correct? Is there a limit to 65555?

When I receive requests that are of CurSize = 40000 e.g. the commands
#STD_NUM := #Reader.ReadNumberWithName( "total" )
#Reader.BeginArrayWithName( "data" )
#Reader.BeginObjectAtIndex( 1 )
#STD_TEXT := #Reader.ReadStringWithName( "orderNumber" ).AsNativeString
#STD_TEXTL := #Reader.ReadStringWithName( "currencyId" ).AsNativeString


retrieve the correct values that I can see in my response.body.log file.

When CurSize is much bigger these commands retrieve no values at all (I suppose because the end of the array structure and other values are not integrated in the string that the reader contains).

How do you handle big amounts of response data in your web APIs?

Kind regards,
Joerg

Re: Web API - XPRIM_RandomAccessJsonReader - Size Limit?

Posted: Tue Sep 06, 2022 7:36 am
by BrendanB
Joerg,

please review:

viewtopic.php?f=4&t=2047

which talks about using #Prim_JsonReader

this works quite well for *Large* data sets.. (there is an example in the last post of it..)

Brendan.

Re: Web API - XPRIM_RandomAccessJsonReader - Size Limit?

Posted: Wed Sep 14, 2022 10:34 pm
by Speedlime
Has anyone got a working example of using #XPRIM_RandomAccessJsonReader, I followed the simple examples in manual but I am not sure if it is the size of the Json returned that is the issue, or if it my code. The Json is only 6.56 KB using V15 150040 epc

DEFINE_COM Class(#XPRIM_RandomAccessJsonReader) Name(#Reader)
IF (#Request.Response.IsSuccessfulRequest)
IF (#Request.Response.IsSuccessHttpStatusCode)

#Reader.SetSourceHttpResponse Httpresponse(#Request.Response)

#Reader.BeginObjectWithPath( 'consignment' )
* fields are type string
#LMCNCOD := #Reader.ReadStringWithName( 'consignmentCode' ).AsNativeString
#LMCNSTS := #Reader.ReadStringWithName( 'status' ).AsNativeString
#LMCCCOD := #Reader.ReadStringWithName( 'carrierConsignmentCode' ).AsNativeString
#Reader.EndObject

#Reader.BeginObjectWithPath( 'consignment/paperwork' )
* fields are blobs
#LMCNLBL := #Reader.ReadStringWithName( 'labels' ).AsNativeString
#LMCNCDS := #Reader.ReadStringWithName( 'customs' ).AsNativeString
#Reader.EndObject

Endif
Endif

Any help will be greatly appreciated

Re: Web API - XPRIM_RandomAccessJsonReader - Size Limit?

Posted: Fri Oct 14, 2022 3:08 am
by Speedlime
Turns out the payload was empty on the return, so the coding is correct.

API logging as specified in the June 2022 Technical Newsletter works well. (attached)
In the logging data you can see the request and response bodies. Great help when developing and testing.

Important entries to add to the Header

* Additional Header Entries
#Request.Content.ContentInfo.MediaType := 'application/json'
#Request.Options.AddHeader Name('Accept') Value('application/json')


The top one tell the server you are sending and talking Json and the second instructs the server being called you want Json returned.