The problem is caused by the xml content with the header. When we remove this content, the pdf file displays correctly.
The question is whether the Resourcepath content can be written to a string variable?
Because if I do this with a Result variable, the binary string is different from the ResourcePath (probably different encoding) and then the file is damaged
Dim myReq As System.Net.HttpWebRequest
Dim myResp As System.Net.HttpWebResponse
myReq = System.Net.HttpWebRequest.CreateHttp("URL")
myReq.Method = "GET"
myResp = DirectCast(myReq.GetResponse, System.Net.HttpWebResponse)
statusCode = myResp.StatusCode
statusDescription = myResp.StatusDescription
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
myText = myreader.ReadToEnd
I’ve got a similar problem. A bot upload the file (in my case it’s an Outlook message) to an external system. The uploading runs well. However when I download (manually) the file on my PC I cannot open it because the file is corrupted. On top and at the bottom of the file are added some rows like you can see. I’m curious to understand how you have solved it.
Thanks for your help
I have already implemented this solution inside my workflow and it works fine!
Means that the file is saved in my folder correctly.
The problem happens when I use HTTP Request and I try to upload the file with a Post method in the company external system. The file is uploaded but is CORRUPTED.
For an unknown reason some rows are inserted on top and at the bottom of the file like previously posted.
The proof is if I remove these rows the file is opened perfectly.
Another strange thing is that if I try to post the same file using POSTMAN I can do it perfectly and the file once posted is downloadable without errors.
I setted in HTTP request the same parameters of POSTMAN, but doesn’t work in the same way!!.
I haven’t tested yet, but you might want to use the MimeKit library
Dim oRequest As System.Net.HttpWebRequest = CType(HttpWebRequest.Create("https://samplewebservice.com"), HttpWebRequest)
Dim msg As MimeEntity
Dim mime_Ct As MimeKit.ContentType
Dim mime_part As MimeKit.MimeEntity
mime_part= MimeEntity.Load(mime_ct, oRequest.GetRequestStream())
Dim muli_part As MimeKit.Multipart
Dim i As Integer
For Each attachment As MimePart In muli_part
Dim filename As String
filename = "attachment"+CType(i,String)+".txt"
Dim stream As New FileStream(filename,FileMode.Create)
Thanks, You are telling me that I must to install the Mimekit package.
OK. I can do it, but I have no idea about how to invoke your code. Plz, can you post an example that explain how to run the code inside a workflow?
Ad2. Yes, The red text is example
Ad3. Can you tell me what service it is (REST, SOAP)?
Maybe you will need authorization - login or password, certificate etc.
Describe the attachments (extension) and sample answer