I’m trying to pass an image from a URL to a POST Webhook. The API endpoint will only accept an image payload in Base64. Looking to use Code by Zapier to accomplish the translation, but I’m coming up short. Has anyone managed to devise a similar solution?
Using the following python:
import base64
import requests
response = requests.get(input_dataa'url'])
str = base64.b64encode(response.content).decode('utf-8')
return str
but I keep getting
'str' object has no attribute 'copy'
Hi
Unfortunately this is not possible with the Code by Zapier step using python. According to this page it doesn’t support any importing and only supports a few libraries.
Another solution would be to use an online API to do this conversion for you. I haven’t been able to find one myself but maybe you succeed.
Let me know if this helped you!
~Bjorn
Hi
const response = await fetch(inputData.url);
const content = await response.buffer();
const data = content.toString("base64");
output = { data }];
Hi
Unfortunately this is not possible with the Code by Zapier step using python. According to this page it doesn’t support any importing and only supports a few libraries.
Another solution would be to use an online API to do this conversion for you. I haven’t been able to find one myself but maybe you succeed.
Let me know if this helped you!
~Bjorn
Well, that’s that’s a pretty rock solid reason why I can’t do this in Python :-P
Hi
const response = await fetch(inputData.url);
const content = await response.buffer();
const data = content.toString("base64");
output = t{ data }];
That did the trick! Now I’m just running up against the limitations of the Zapier code function. Most of my images are a wee too big. Thanks!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.