Question
· Apr 13, 2023

Read a long Stream into JSON Dynamic Object - MAXSTRING error

I am trying to read binary data from HTTP Request Stream and build a Dynamic Object with multiple properties. I am getting MAXSTRING error with this code:

 Set dynObject1 = ##class(%DynamicObject).%New()
 Set dynObject1.OriginalFilename = $P($P(request.HTTPHeaders.GetAt("RawParams"),"&",2),"=",2)
 Set dynObject1.SiteId = $P($P(request.HTTPHeaders.GetAt("RawParams"),"&",1),"=",2)
 For {
   Set len = 1000000
   Set tRead = request.Stream.Read(.len,.sc)
   Set ^TESTutil($INCREMENT(^TESTutil),"len") = len
   Set ^TESTutil($INCREMENT(^TESTutil),"sc") = $Get(sc)
   If (len < 1) Quit }
   Set dynObject1.Stream = dynObject1.Stream_tRead
   Set len = $Length(dynObject1.Stream)
   Set ^TESTutil($INCREMENT(^TESTutil),"len2") = len
 }
 Set tStream = ##class(%Stream.GlobalCharacter).%New()
 Set tSC1 = tStream.Write(dynObject1.%ToJSON())
 Set ^TESTutil($INCREMENT(^TESTutil),"tSC1") = tSC1
 Set tSC2 = tStream.%Save()
 Set ^TESTutil($INCREMENT(^TESTutil),"tSC2") = tSC2
 Set context.GenericMessage = ##class(EnsLib.HTTP.GenericMessage).%New(tStream)
 Do context.GenericMessage.SetHTTPHeaders("URL=cdw/api/file/new")
 

Product version: IRIS 2022.2
Discussion (5)1
Log in or sign up to continue