XML file in form-data
Hello everybody
I'm trying to send a XML file in a form-data like this, but is not working. Can anyone help me with the code?
This is my code:
Set RootMIMEPart = ##class(%Net.MIMEPart).%New()
Set BinaryMIMEPart = ##class(%Net.MIMEPart).%New()
Set stream = ##class(%FileBinaryStream).%New()
Set stream.Filename = pRequest.file
Do stream.LinkToFile(pRequest.file)
Set BinaryMIMEPart.Body = stream
// I already used "application/x-www-form-urlencoded", "application/xml", "application/x-object" in Content-Type
Do BinaryMIMEPart.SetHeader("Content-Type", "application/x-www-form-urlencoded")
Do BinaryMIMEPart.SetHeader("Content-Disposition","form-data; name=""file""; filename="""_pRequest.file_"""")
S status = RootMIMEPart.Parts.Insert(BinaryMIMEPart)
Set writer = ##class(%Net.MIMEWriter).%New()
D writer.OutputToStream(HttpRequest.EntityBody)
D writer.WriteMIMEBody(RootMIMEPart)
Set HttpRequest.ContentType = "multipart/form-data; boundary="_RootMIMEPart.Boundary
Do HttpRequest.SetHeader("Content-Type", "multipart/form-data")
Set status = HttpRequest.Post(..Adapter.URL)
Set tResponse = HttpRequest.HttpResponse
you set content-type application/x-www-form-urlencoded
BUT
is your content really urlencoded ?
If NOT, decoding it may create some chaotic nonsense and definitely no XML
I´ve already used this types:
All of them with tha same result, like the xml file was not attached
That is the correct result:
I´ve already used this types:
All of them with tha same result, like the xml file was not attached
That is the correct result:
Correct answer:
https://community.intersystems.com/post/httprequest-post-file-upload-mul...