· Jul 23, 2018

Caché CSP REST <MAXSTRING> error when writing back the response

I'm trying to have my REST service return the entire data set for one of our legacy globals.  Currently I am parsing the object from a SQL statement into generic objects to be returned like this:

         Set specimenArray=[]
        WHILE resultSet.%Next() {
            Set specimen = {}
            Set specimen.SpecimenId= resultSet.SpecimenId
            Set specimen.ProjectId = resultSet.ProjectId
            Set Oref = specimenArray.%Push(specimen)
        Set tProxy = specimenArray.%ToJSON()
        set %response.Status = 200
        set %response.ContentType = "application/json"
        Set %response.CharSet="utf-8"

        Write tProxy

However, since the dataset is massive, it returns a <MAXSTRING> error.  When I limit the SQL to "TOP 500" it works perfectly and  I am certain I need to do some sort of stream back, but unsure of how to do that.  Any pointers of how I can take this array and stream the JSON back?


Discussion (2)1
Log in or sign up to continue