Recent posts:
Recent replies:

Hi Marc,

1. I built ASP.NET some "server" http listener with [HttpPost] controller

2. I activate your code meanwhile on 1 file (.pdf)

with URL ...serverAsp/postfile/ ...

and got correctly the "file" from your POST() code, means in .NET:

var request = System.Web.HttpContext.Current.Request;

            var files = request.Files.Count;

---> files.Count = 1

so .NET server recognized multi-part structure with 1 file !

4. I saw you made little changes to Craig code, and made it more simpler with just .Post(Url),  without any "adapters"... and nor .SendFormDataArray... 

that did not work for me in the beginning.

5. I'll made more testing , to see if the whole file is transfered correctly

but its seems to work.


Hi Marc,


P1   ;

           Set url = HOST_"http://"_HOST_":"_PORT_"/"_jq
           Set tSC = httpRequest.SendFormDataArray(.httpResponse,"POST", httpRequest, "", "", url)

         //Set rc=httpRequest.Post(jq)

the error I get:

<METHOD DOES NOT EXIST>P1+2^HTTP3 *SendFormDataArray,%Net.HttpRequest

2. I asked berfore:

in what Part I set contentDisposition ?

I mean not in SetHeaders,  but as another part in Body ?

or, I don't need it ?

tried multi Part form with one file.pdf to own .Net listener 

the "POST" did not arrive to "web server" ?

my example (took from craig, with some corrections) :

on :


got error, so I tried .POST

code example :

HttpMimeRequest ;
S Q=$C(34)

 S HOST = "" ;"localhost"
 S PORT = "8080"
 Set httpRequest=##class(%Net.HttpRequest).%New() 
 Set httpRequest.Server=HOST
 Set httpRequest.Port = PORT

 // Create root MIMEPart
 Set RootMIMEPart=##class(%Net.MIMEPart).%New()

 //Create binary subpart and insert file data
 Set BinaryMIMEPart=##class(%Net.MIMEPart).%New()
 Set contentDisp=""
 Set contentDisp=contentDisp_"form-data; name="_Q_"fileUpload"_Q
 Set contentDisp=contentDisp_"; filename="_Q_file_Q
 ;Set BinaryMIMEPart.ContentDisposition=contentDisp
  Do BinaryMIMEPart.SetHeader("Content-Disposition",contentDisp)
  Set BinaryMIMEPart.ContentType="application/pdf" ;"application/octet-stream"
 Set ContentType= "multipart/form-data; boundary="_RootMIMEPart.Boundary
 Set httpRequest.ContentType=ContentType

 // do we need it : ?
 Do BinaryMIMEPart.SetHeader("Content-Type", ContentType)

 Set stream=##class(%FileBinaryStream).%New()
 Set stream.Filename=file
 Do stream.LinkToFile(file)
 Set BinaryMIMEPart.Body=stream

 // Insert both subparts into the root part
 Do RootMIMEPart.Parts.Insert(BinaryMIMEPart)

 // create MIME writer; write root MIME message
 Set writer=##class(%Net.MIMEWriter).%New()

  // Prepare outputting to the HttpRequestStream
  Set status=writer.OutputToStream(httpRequest.EntityBody)
  if ('status) {do $SYSTEM.Status.DisplayError(status) Quit}

 // Now write down the content
 Set status=writer.WriteMIMEBody(RootMIMEPart)
 if ('status) {do $SYSTEM.Status.DisplayError(status) Quit}

 //  QueryString Example ;
 Set jq = " index.htm?CUSTID=myCust"

 //set url="alfresco/service/sample/upload.json?"
 //      _"alf_ticket=TICKET_caee62bf36f0ea5bd51194fce161f99092b75f62"
 ;set url="http://localhost:8080"
 ;set status=httpRequest.Post(url,0) 
 ;if ('status) {do $SYSTEM.Status.DisplayError(status) Quit}
P1 ; 
 ;Set url = HOST_"http://"_HOST_":"_PORT_"/"_jq
 ;Set tSC = httpRequest.SendFormDataArray(.httpResponse,"POST", httpRequest, "", "", url)
  Set rc=httpRequest.Post(jq) 

Emanuel has no followers yet.
Emanuel has not followed anybody yet.
Global Masters badges:
Emanuel has no Global Masters badges yet.