HTTP REQUEST - POST - UNRECOGNIZED UPLOADED FILE

Hi all,
I’m trying to upload a file to an external system, using the HTTP REQUEST and the POST Method.
As test I’ve tried to use Postman, that I’ve configured with headers, authorization (simple HTTP with username and password) and a body with the file that I upload in binary format.
All works fine and once uploaded I can open my file without problem.
Then I’ve replicated all these settings using the HTTP REQUEST (except the binary feature) and I can upload the file, but If I try to open the file downloaded I can’t open it.
The file is an Outlook message, so it’s already in a binary format.
Editing the file with NOTEPAD++ I discovered that on top of the file has been added some rows and a couple of rows also at the bottom. If I remove these rows I can open it …
This an example of rows added
-------------------------------28947758029299
Content-Type:
Content-Disposition: form-data; name=“application/json”

{
‘Document’: ‘0200403_12305095_postacert.eml (13.3 KB).msg’
}
-------------------------------28947758029299
Content-Disposition: form-data; name=“path”; filename=“20200403_12305095_xxx.eml (13.3 KB).msg”
Content-Type: application/octet-stream

In Uipath I’ve tried also to remove the header, but as result I obtain an “Untitled Document From Web API”.

Someone can help me?
Thanks I appreciate

@ro.bot - can you able to share both Postman & HttpRequest property screenshots?

Sure,
These are the Postman screenshots


and here the HTTPRequest screenshots

Did you ever get it working?

Hello Lucius,
In these videos you will see how I attached files in different system like ServiceNow and Jira:

Thanks,
Cristian Negulescu

Hello,

Please try below C Sharp Code and add this in your invoke code activity. This basically converts the file into binary code and then uploads in the target system.

Byte[ ] fileBytes = File.ReadAllBytes(in_strFilePath);

RestSharp.RestClient client = new RestSharp.RestClient(in_strEndpoint);
RestSharp.RestRequest request = new RestSharp.RestRequest(RestSharp.Method.POST);

request.AddHeader("<<Put Your Header Key>>", in_strDocumentName);
request.AddHeader("<<Put Your Header Key>>, in_strAPIKey);
request.AddHeader("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

// Add the file content as bytes to the request body
request.AddParameter("application/octet-stream", fileBytes, RestSharp.ParameterType.RequestBody);

// Execute the request
RestSharp.IRestResponse response = client.Execute(request);
Console.WriteLine("Response Status Code: " + response.StatusCode.ToString());