Upload an document with an error using HTTP request

I need an urjunt’s help; please help me out. Thank you in advance.

I need to upload a document (PDF, XLSX, or doc) to a client site using an HTTP request. I tried to upload, and I can upload to the client site but can’t open the documents that are uploaded to the client site. and if we try to save and open, we can open the document, but with an error.

When we try to upload from Postman, it works fine.

Any suggestions?

2nd, when we try to open the document directly from the Clinet site,

first : screen error once we download the document

Hi @manipreethi410

Check on this thread

I hope it helps!!

I couldn’t find the proper code.

Hello,

Please try below C Sharp Code and add this in your invoke code activity.

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());