httpRequest POST file Upload multipart
httpRequest POST file Upload multipart
1. is there a code example step-by-step, how to build each part ?
I tried the demo from intersystems doc's,
I checked it in .Net response, that didnot recognize the File-data part
2. I noticed, there is :
SET BinaryMIMEPart.ContentType="application/octet-stream"
but missing :
SET BinaryMIMEPart.ContentDisposition (as analogue, let say for VBA EXCEL )
or I do it via the:
Do BinaryMIMEPart.SetHeader("Content-Disposition",...) ?
that is not analouge for VBA
need any code example link, to execute correctly all the multipart (cache call it MIMEtype)
settings
Product version:
Ensemble 2018.1
I had the same challenges as you when I was tackling this - documentation wasn't really fleshing it out well enough. ISC Sales Engineer helped me work through it.
Here is what I have used with success to submit both an XML doc and PDF doc to a vendor along with two parameters associated with the request (ReportId and CustomerId.) Requires use of MIME Parts. I hope this helps you. I had to genericize some of the code to share but it is commented by me what each part does and how it pulls together.
Note this assumes you're passing in a variable pRequest that is a message class that holds your data. Also I am running this on 2019.1, not 2018 so not sure of the differences when using things like %JSONImport (may be none but I don't know that for certain.)
Hi Craig,
I followed your code, there some obstacles, that I cannot implement your example :
1. I run the from standard Module.int (not class)
2. what is the syntax : ..%HttpRequest.SetHeader(...) ?
3. what is : ..Adapter.SendFormDataArray(.tHttpResponse,"POST", ..%HttpRequest, "", "", tURL) ?
what the ..Adapter means in standard module ?
I used just :
Set RootMIMEPart=##class(%Net.MIMEPart).%New()
Set BinaryMIMEPart=##class(%Net.MIMEPart).%New()
Set contentDisp=contentDisp_"form-data; name="_Q_"fileUpload"_Q
BPT> Set contentDisp=contentDisp_"; filename="_Q_file_Q
SET contentDisp=contentDisp_"; filename="_Q_file_Q
Set BinaryMIMEPart.ContentDisposition=contentDisp
Do BinaryMIMEPart.SetHeader("Content-Disposition",contentDisp)
Set BinaryMIMEPart.ContentType="application/octet-stream"
and so on...
using standard objects
I'm not really clear on what you mean by "standard Module.int" so sounds like we may be approaching this in different ways and I apologize for any confusion I caused.
%HttpRequest is %Net.HttpRequest (you can find syntax for SetHeader here) and the Adapter in this case refers to the adapter attached to the EnsLib.REST.Operation class via Parameter, which in this case is EnsLib.HTTP.OutboundAdapter.
Emanuel,
Since you're writing this in a normal .int, you won't want to use "..%HTTPRequest". You can just instantiate a new request object and name it something like httpRequest:
And instead of Craig's ..Adapter call, you can use httpRequest's Post method.