I need help with sending file uploads through Python code in Zapier. I’m trying to automate file submissions to an external API but running into issues.
What works: I can successfully send files using Postman with this Python code:
The problem: When I copy this to Zapier Code, I don’t know how to handle the actual file data. My Zapier trigger gets email attachments that show up as hydrated content like this:
How do I properly connect the hydrated file from Zapier’s email trigger to the Python multipart request? I’m not experienced with file handling in Zapier automation workflows.
I’ve hit this exact problem before - there’s an easier way. You’re making the file handling way too complicated by building multipart boundaries manually. With Zapier’s hydrated files, just pass the file reference directly and skip all that extra work.
Here’s what actually works: grab the hydrated file from your trigger data like file_content = input_data['attachments'][0] for the first attachment, then drop it straight into a normal requests call. Zapier automatically converts the hydrated content to proper binary data.
Ditch that manual Content-Type header completely - it’s screwing things up because your boundary doesn’t match what requests creates internally. Just let Python handle the multipart encoding and boundary stuff automatically.
hey, zapier handles hydrated files differently than raw file data. use the requests.files parameter instead of building multipart data manually. try files = {'upload': input_data['file']} then requests.post(url, files=files, params=params) - zapier converts the hydrated content automatically when you reference it right.
You’re manually building the multipart boundary instead of letting Python do it for you. That’s your problem. With Zapier’s hydrated files, don’t set the Content-Type header manually - requests will generate the right boundary automatically.
Here’s how to fix your code:
import requests
api_endpoint = "https://api.example.com/upload/files"
params = {"access_token": "sample_token_12345", "filename": "document.pdf"}
# Let requests handle the multipart encoding
files = {'upload': ('sample.png', input_data['attachment'], 'image/png')}
# Remove the content-type header - requests will set it correctly
headers = {'cache-control': "no-cache"}
result = requests.post(api_endpoint, files=files, headers=headers, params=params)
print(result.text)
Zapier converts hydrated content automatically when you reference it through input_data. Use the files parameter with a tuple (filename, file content, mime type) instead of building raw multipart data yourself.
I’ve been wrestling with file uploads across automation platforms for years. The real problem isn’t hydrated files - it’s that Zapier just can’t handle complex file operations well.
Zapier’s Python environment is way too restrictive for file manipulation, and their hydrated content system makes everything unnecessarily complicated. You end up fighting the platform instead of getting stuff done.
I jumped to Latenode for exactly this reason. It handles file uploads natively without all that hydration garbage. You can grab email attachments and shoot them to any API using proper multipart form data.
With Latenode, you pull the file from your email trigger and send it straight to an HTTP request node. No manually creating boundaries, no hydrated content hacks. The platform handles multipart encoding automatically while you keep full control over headers and parameters.
Bonus: you can actually see each step of your file processing workflow instead of debugging Python in a black box. Way cleaner for file automation.
zapier’s hydration system is weird but it works. skip creating form data manually - just grab the hydrated file with zapier_file = input_data['hydrate_file'] then use files={'upload': zapier_file}. let the requests library handle multipart encoding automatically. don’t set content-type headers yourself or you’ll break everything.