1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Zapier Code: Python Http

Discussão em 'Python' iniciado por Stack, Junho 25, 2025.

  1. Stack

    Stack Membro Participativo

    I've got a simple python script that queries an API (using the requests library), parses the returned JSON, and builds a redirect URL based on the data returned from the API. The script works as a local python script run from my machine.

    My goal is to have a URL that a user opens in their browser, which triggers the python code to run, build the redirect URL, and redirect the user to this new URL.

    Can I use Zapier Webhooks + Zapier Code to achieve this?

    The Python looks like this (details changed):

    # A constant for the API query
    query_str = "123"

    # A constant in the redirect URL
    resultant_constant = "93093"

    # Personal Access Tokenfor this service
    app_id = "the_app_id"
    secret = "the_secret_key"

    # Make API call and get a the JSON response
    resp = requests.get('https://api.example.com/path/to/endpoint/'+ query_str +'/endpoint?filter=theFilter&order=sort_date', auth=(app_id,secret))

    # Gets the id of the object I want
    my_id = resp.json()['data'][0]['id']

    report_url = "https://subdomain.example.com/path/"+resultant_constant+".ext?&object_id="+my_id

    return report_url

    Continue reading...

Compartilhe esta Página