If the file isn't accessible to link to directly, you may want to look into extending the %CSP.StreamServer class and linking to that. At a bare minimum, you'll want to override the OnPage and OnPreHTTP methods:

ClassMethod OnPage() As %Status
{
set myfile = ##class(%File).%New("/path/to/file")
do myfile.Open("S")
do myfile.OutputToDevice()
quit $$$OK
}

ClassMethod OnPreHTTP() As %Boolean [ Language = cache ]
{
do %response.SetHeader("Content-Disposition","attachment;filename=""filename""")
quit 1
}

Of course using your own file name and the path to the file. That's the local computer file path, not a URL. You also should set the content type appropriately using set %response.ContentType = "text/csv" or whatever the MIME type of the file is so that the browser can identify it correctly.

Unless you want to have to write another %CSP.StreamServer for every file, you'll have to pass the name of the filepath as an argument. So that would look more like:

ClassMethod OnPage() As %Status
{
set myfile = ##class(%File).%New(%request.Get("filepath"))
do myfile.Open("S")
do myfile.OutputToDevice()
quit $$$OK
}

ClassMethod OnPreHTTP() As %Boolean [ Language = cache ]
{
set filepath = %request.Get("filepath")
set %response.ContentType = "text/csv" //or whatever the appropriate MIME type is
do %response.SetHeader("Content-Disposition","attachment;filename="""_$P(filepath,"/",*)_"""")
quit 1
}

Then you could link to it as whatever the path to your stream server is with ?filepath=/path/to/file on the end.

If you take that approach, though, do some validation on the filepath and make sure it can ONLY go to the folder you want! Or, only pass the filename as a parameter to the page, and hard-code the folder in those methods.

It looks like in your curl you have the Accept header as */*, but in your HttpRequest object, you're setting it to "application/json". Does that make a difference?

Are you just trying to get the json contained in a character stream into a string a vice versa? If so, just read and write to and from the stream:

set json = ""
while 'stream.AtEnd
{
    set json = json_stream.Read()
}

That should get you the contents of the stream into a string.

do stream.Write(json)

That should write the json to a stream.

Or is that not what you're trying to do?

There isn't a hard limit on the number of tasks, but you may run into licensing issues. As you set them up, you choose the user they run as, so if that user has too many connections going at once, or if they're run as more different users than you have licenses for, there could be an issue.

Once you know the pid, try:

set process = ##class(%SYS.ProcessQuery).%OpenId(pid)

Then check process.Routine, or process.CurrentLineAndRoutine.

Here's how I've been doing this:

//Read in content from the HttpRequest
set req = %request.Content.Read()

//Convert content from JSON to a dynamic object
set reqObj = {}.%FromJSON(req)

//Access data from within the new dynamic object
set userName = reqObj.%Get("UserName")

Why not do this?

set rset1 = ##class(%ResultSet).%New() 
set query = "Select statment" 
set sc = rset1.Prepare(query) 
set:+sc sc = rset1.Execute(parm1, parm2) 
set ^sql = query

Have you checked the security settings for the user you're logging in as? You should have %Developer and %DB_USER, I think. Or if you have %All, that works too.

This is a long shot, but is the ODBC connection defined in User DSN or System DSN? We had an issue after a recent round of Windows updates where Excel suddenly wasn't always correctly seeing the System DSN connection, and setting it up under User DSN instead resolved that issue.

Here is some useful documentation.

You're going to want to make a class that extends %CSP.REST and set up an application that uses that class as its dispatch class. You'll have a URL map in that class to tell IRIS or Cache what to do with the request. Depending on your specific application, you might also want to get familiar with using %request and %response in that process.