Rochdi, when you say you've figured out how to save it to C:\Temp\filename.csv, are you saying you have it saved on the client, or on the server?

If it's saving the file on the server, you can create a class that extends %CSP.StreamServer, then override the OnPreHTTP and OnPage class methods like this for simple text files:

 Class fileserver Extends %CSP.StreamServer
{ 
ClassMethod OnPreHTTP() As %Boolean
{
do %response.SetHeader("Content-Type","text/csv")
do %response.SetHeader("Content-Disposition","attachment;filename=""myfile.csv""")
quit 1
} 
ClassMethod OnPage() As %Status
{
set file = ##class(%File).%New("/path/to/file.csv")
do file.Open("R")
while file.AtEnd '= 1{
write file.ReadLine(),!
}
quit $$$OK
} 
}

and then just link to it that page to download.

Once you get to things that aren't plain text, it gets a little more complicated, but this should work for a simple csv.

Your result set should be an EnsLib.SQL.GatewayResultSet, which has a method called GetSnapshot(). That method has you pass a EnsLib.SQL.Snapshot by reference. You're probably going to want to set the FetchAll parameter on the GetSnapshot() method to 1 so it gets all the results, but you can also create your EnsLib.SQL.Snapshot before using GetSnapshot() and set it's starting row and max rows if you'd like. Then you can iterate over the snapshot instead of the result set. Once you've gone through it once, you could either create a new snapshot by calling the GetSnapshot() method again, or you can use the snapshot's Rewind() method.

According to this page, if it's something that still in development, you can use the CleanProduction() method to clear the message queues. Using it in a live system isn't recommended because it clears out everything pretty indiscriminately, but it's useful for debugging.

Productions get the suspend status when after shutting down there are still synchronous messages that could not be processed.

MAXSTRING usually indicates that you're exceeding the maximum possible length of a string somewhere. Are you sure it's a problem with the %Stream.GlobalCharacter, and not a different string variable in your program? Global character streams shouldn't have that problem.

You can see what the maximum length of a string is on your system by opening a terminal and running:

write $SYSTEM.SYS.MaxLocalLength()

I've had some time to try this now. Here are steps that worked for me:

set myrequest = ##class(%Net.HttpRequest).%New()
set myrequest.Server = "<server ip or domain here>"
set myrequest.Port = "<server port here if it isn't 80>"
set myrequest.Location = "</path/to/rest>"
do myrequest.EntityBody.Write("<your json here>")
do myrequest.Post()
set mydata = myrequest.HttpResponse.Data.Read()

At that point, the data returned in the response should be in mydata.

Depending on your specific API, you made need to take additional steps for authentication, and you may need to use myrequest.Get() or myrequest.Put() instead of myrequest.Post().

If you need to set parameters, you use the SetParam method of the HttpRequest. For example, if you're using the very most basic way to authenticate to a Cache instance, you do that by specifying a CacheUserName and a CachePassword as parameters as follows any time before your post/put/get:

do myrequest.SetParam("CacheUserName","<your username here>")
do myrequest.SetParam("CachePassword","<your password here>")

Somewhere in your button tag, you have onselect= something. Buttons don't have an onselect, but even if they did, I'm guessing that's not the event you actually want. onselect happens when a user highlights text within a control, like in a text input.

If you're trying to set what happens when the user clicks the button, that's onclick.

If you're trying to set what happens when the user selects the button but doesn't click it (say by pressing tab until the button is highlighted) that's onfocus.

I think you're looking for the %ArrayOfObjects class for this one. You'd create your objects with all of their value, ID, and type properties, then you'd create the array:

set array = ##class(%ArrayOfObjects).%New()

Then you set values of the array using the SetAt method:

do array.SetAt(downobject,"down")

Then to access a particular value, you use the GetAt method, then dot syntax to access the object's properties:

set myid = array.GetAt("down").id

Here's the %ArrayOfObjects class documentation.

Try replacing your while loop with this:

//set RET to a blank string to start to avoid issues with the first concatenation inside the loop
s RET = ""
while res.Next()
    {
     //Append a ~ and the value to RET
     s RET = RET_"~"_ res.GetData(2)
}
//The way we did this, RET will now start with a ~, which we'll want to remove
//This will look at RET, replace tildes with nothing, starting at the beginning, and only making one replacement
$REPLACE(RET,"~","",1,1)

//having done that, RET should now be, "description 1~description 2"