Needed Help! How to properly upload Base64 files to OneDrive

I use a web-based tool (Webform) to submit project information and files. When I fill out the webform, upload the files, and hit submit, the data is sent directly to Make via a webhook. I want to upload files directly to OneDrive (SharePoint). The file uploads to SharePoint, but when I open it, an error appears stating the data does not exist.

The webhook provides file data in Base64.

After the webhook module, I added a “Set Variable” tool to decode Base64 to binary.

Then, I added a OneDrive module to upload the file, which uploads successfully to SharePoint, but opening the file results in an error indicating the data does not exist.

Could you please help identify what I am doing wrong and guide me on how to resolve this issue?

Thank you

Hi @Urjit_Hirani - try extracting just the base64 string from the data key you receive in your webhook.

data:application/pdf;base64,<THIS IS THE BASE64 STRING>

You can use a split() function to split the string into two parts - one containing data:application/pdf;base64 and the other containing <THIS IS THE BASE64 STRING>.

And then use last() formula to grab only the second part:

{{last(split(1.files[].data; ","))}}

When you include that in your current toBinary() formula, it will look like this:

{{toBinary(last(split(1.files[].data; ",")); "base64")}}

Try copy-pasting the above formula in your “Set Variables” module or directly in the OneDrive module instead of the 1 variable. Report back if that won’t work. :slight_smile:

Cheers!

3 Likes

Hi @SierraV, I tried the way you mentioned, and it worked in one run. Now I know where I went wrong; instead of taking only , I was taking the entire dataset, including application/pdf:base64.

Thank you for helping me with this issue quickly; I appreciate it a lot.