Upload xlsx file with API

Pavel_Soucek
New Contributor II

Hello, I would like to upload xlsx files from SharePoint to Databricks (AWS).
I have files in my Sharepoint folder, try to use power automation (like if new file is created upload file to Databricks) and custom connector (where I defined API /api/2.0/fs/files{file_path}). I am able to to upload file, but I have an issue with (maybe) file codeing and I on Databricks a I can not open/read the file. Have i different content. 

My steps in power automate:

1.Get File Content

2. Compose (decodeBase64(outputs('Get_file_Content')?[body]['$content'])

3. Upload file to Databricks (API) - Content-Type: application/octet-stream, Body: (outputs(Compose)

both files (on SharePoint and on Databricks, when I open them in Notepad looks similar, but not not exactly same).

Is anyone successful with similar task?

 

Thank you

Pavel

szymon_dybczak
Esteemed Contributor III

Hi @Pavel_Soucek ,

The Excel files are binary formats. I think when you are using decodeBase64() on the file content, you might corrupting the file accidently. I think Power Automate already returns the binary data in a format suitable for sending in the body of an HTTP request.
Could you try replace your code with following?

@body('Get_file_Content')

Also, documentation of the endpoint you're using suggest to not encode anything, so let's try above approach.

szymon_dybczak_0-1751281292241.png

 

 

I have tried it with tis error message:

Flow save failed with code 'OpenApiOperationParameterValidationFailed' and message 'Input parameter 'body' validation failed in workflow operation 'UploadFile': The parameter with value '"@body('Get_file_content')"' in path 'body' with type/format 'String/binary' is not convertible to type/format 'Object'.'.

Maybe i need to somehow define something in the connector, but I don't know what.

p.

szymon_dybczak
Esteemed Contributor III

Hi @Pavel_Soucek ,

It was long time ago since I worked with Power Automate, but I think you can edit connector. You can try to change schema to binary or byte

I can define header and body for "PUT". I add to header "content-type". Bud I am not sure how to define "body".