HTTP request activity with an Excel attachment

Dear community,

I’m pretty new to UiPath and have very little experience with API’s so I’m hoping you’re going to be able to help me.

I’m triggering a BOT via the Orchestrator and then hoping to return an Excel file with an ‘HTTP request’ activity.

I’ve already got another similar process that is returning a PDF file and that is working fine.

The End Point is receiving data but when I try to open the Excel is gives me the following message : “Excel cannot open the file “testfile.xlsx” because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file”

I’m using the POST Method. The BodyFormat is application/xml and I’m simply including the Attachment where I’ve indicated a string variable with the file path and the a Header.

Can you help? Is it possible to pass an Excel file this way?

Thanks in advance.

The files downloaded from internet are blocked for security reasons.
Can you check the properties of Excel and unblock if it is blocked.

Karthik Byggari



have you ever managed to get it working?
I have the same issue right now…

i’m facing the same issue, do you have a solution by any chance? Thanks

yeah, I used invoke code with code below
these headers are to upload to azure blob storage, you will need to replace with the headers that you need.

		 using (System.Net.Http.HttpClient client = new System.Net.Http.HttpClient())
                client.BaseAddress = new Uri("https://"+uri.DnsSafeHost);
				client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
                client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
                client.DefaultRequestHeaders.Add("x-ms-blob-type", "BlockBlob");
                client.DefaultRequestHeaders.Add("x-ms-meta-filename", file.Name);
                client.DefaultRequestHeaders.Add("x-ms-meta-flowname", flowName);
                client.DefaultRequestHeaders.Add("x-ms-meta-hubmsgid", hubmsgid);
                client.DefaultRequestHeaders.Add("x-ms-meta-partlocnid", partnerLocationID);
				var byteContent = File.ReadAllBytes(file.FullName);
                	using (System.Net.Http.HttpResponseMessage response = client.PutAsync(uri.PathAndQuery, new System.Net.Http.ByteArrayContent(byteContent)).Result)
		 catch(Exception e)
						exceptionMessage = e.Message;