I’m working on a Zapier automation using their Code step feature and I need to track URL redirections. I’m using the requests library to make HTTP calls but I can’t seem to get any redirect information back.
The output is always empty even though I know the URL redirects. Zapier documentation mentions that requests is supported but maybe there are some limitations I’m not aware of. Has anyone successfully captured redirect chains in Zapier code blocks before? Is there a different approach I should try or specific configuration needed?
zapier’s requests can be limiting. instead of using requests, try urllib! i had the same prob, switched libs, and it worked. also, double-check if the url redirects in zapier’s setup, it might not be the same as running it locally.
Had this exact problem last month with a link tracking automation. Zapier can’t handle Response objects in the history attribute - they won’t serialize to JSON properly. Here’s what fixed it for me: extract just the URLs from the history objects before returning them. Loop through like this: redirect_urls = [resp.url for resp in url_response.history] and return that list instead. Heads up though - JavaScript redirects won’t show up at all since requests only catches server-side HTTP redirects.
The problem is that requests.history only fills up when the final response URL differs from your original request. Zapier’s environment sometimes doesn’t register redirects properly because of how they handle HTTP requests internally. I ran into this building webhook automations. Setting stream=False explicitly and using a lower-level approach helped. Try capturing response headers first with allow_redirects=False to see the initial redirect, then follow it manually. Also check if the target URL actually redirects when accessed from Zapier’s servers. Some sites serve different responses based on the requesting IP or user agent.