2

I have googled and googled but couldn't find an answer that would work for me so here we go. This is slightly similar to this: Use Python to get image in Zapier but not quite.

The problem: I am making an API call to get an image that's then used in the next step in the Zap. And so I get the bytes object that I somehow need to pass in output that will also make Zapier understand is an image once it goes out of the python code step. (I want the image to be one of the Zapier variables)

I get the code to either run with 'X is not JSON serializable' error or end up with a string as opposed to an image.

Caveats: The API call needs to be authenticated and so I can't just create a link to the image that I access in the next step because it's no longer authenticated and so that doesn't work.

I've tried some decoding but that results in said long string.

Help

1 Answers1

2

I was able to get this to work but had to do so without using the code module. Zapier offers a webhooks zap that you can send HTTP requests through. It allows you to authenticate your requests either using basic authentication or through the header. It will also handle 'parameterizing' your URL with provided query strings.

When the zap receives the requested data it is able, at least in my testing, to determine if there is a file (be it .jpeg, .pdf, etc) included in the response and allows it be used in following steps. When accessing it in subsequent zaps the zapier variable will appear as 'File:(Exists but not shown)'. I successfully uploaded a photo from a free photo generator API to my Google Drive in two steps.

Hope this helps.

You have clarified the platform that you are wanting to upload the picture to. The platform is Convo. I signed up for an account to see if I could get this to work. I was able to upload a photo to a created post using the Zapier Convo integration + the webhooks integration I outlined above. Take a look at the screenshots below, let me know if I am missing anything.

Below is the layout. You can ignore the run python, I just used that as I needed a trigger step to test.

Zap Layout

Just to ensure we are attempting the same thing you can see that I am creating a post in Convo:

Convo Settings

This is just a bare-bones post creation. Note the file field in the attachment field at the bottom of the screenshot.

Convo Post Settings

And finally you can see in the screenshot below the post has successfully been created with the photo attached.

Output

Let me know if I am misunderstanding some requirements. I did not have to make any modifications to the image file for this to work.

Michael Case
  • 508
  • 4
  • 13
  • This is super useful. Another problem that I get now, is that I get the image file back but it's not saved as an image (it's a file without any extension). So when I use it in the next step (I want to attach it to a convo post), I have to download the file, add '.png' to be able to open it correctly. Do you know if there's a way to force an extension? – Hania Nykowska Nov 29 '19 at 10:02
  • What is the platform you are trying to upload the photo to? I assume you are using Zapier to upload the photo to a convo as well? – Michael Case Nov 29 '19 at 20:31
  • I'm using Tableau webhooks to get the link and preview image of a new workbook on Tableau Server (not sure all of this information is necessary) Then, I want to create a convo post with that link and the preview image using Zapier for it. I know some people got it to work with a JavaScript code but I'm trying to find an alternative way. – Hania Nykowska Dec 02 '19 at 16:11
  • Hey Hania, I guess I'm just trying to understand what you are trying to achieve after you have received the image from Tableau. You mentioned you would like to upload it to a convo, what platform is the 'convo' taking place on? – Michael Case Dec 02 '19 at 19:27
  • Right. I think convo is the platform (app.convo.com) - it's like a communication application (somewhere between slack and facebook I suppose). Convo has its app on Zapier to build integrations. When creating a post you can add an attachment. From what I've looked at so far it seems that Zapier doesn't recognise the image format and so it doesn't forward it to convo. Does that make sense? – Hania Nykowska Dec 03 '19 at 12:23
  • Sorry for no response (got buried with other work). Could you share the set up of your GET step? I wonder if that's where the problem is... The images I get posted to convo have no extension and have no preview. If I download the file and manually add '.png' to the file name, I get the right image – Hania Nykowska Dec 19 '19 at 10:00
  • No sweat. I wonder if it doesn't have more to do with where you are retrieving the pictures from. Could you try making a GET request to the picsum photo API (https://picsum.photos/). That is the service I made my GET request to. If that still doesn't work I can add some photos of my GET step so you can compare. – Michael Case Dec 19 '19 at 18:02