All Apps and Add-ons

Problems calling a webhook

davedeluxe
Engager

Hi,
can someone help me? I'm trying to call a webhook on AWX Tower (Ansible) using the Add-On Builder.
This is my script but it doesn't work, but I don't get an error message either:

 

# encoding = utf-8
def process_event(helper, *args, **kwargs):
    """
    # IMPORTANT
    # Do not remove the anchor macro:start and macro:end lines.
    # These lines are used to generate sample code. If they are
    # removed, the sample code will not be updated when configurations
    # are updated.

    [sample_code_macro:start]

    # The following example gets the alert action parameters and prints them to the log
    machine = helper.get_param("machine")
    helper.log_info("machine={}".format(machine))


    # The following example adds two sample events ("hello", "world")
    # and writes them to Splunk
    # NOTE: Call helper.writeevents() only once after all events
    # have been added
    helper.addevent("hello", sourcetype="sample_sourcetype")
    helper.addevent("world", sourcetype="sample_sourcetype")
    helper.writeevents(index="summary", host="localhost", source="localhost")

    # The following example gets the events that trigger the alert
    events = helper.get_events()
    for event in events:
        helper.log_info("event={}".format(event))

    # helper.settings is a dict that includes environment configuration
    # Example usage: helper.settings["server_uri"]
    helper.log_info("server_uri={}".format(helper.settings["server_uri"]))
    [sample_code_macro:end]
    """

    helper.log_info("Alert action awx_webhooks started.")

    # TODO: Implement your alert action logic here
    
    import requests

    url = 'https://<AWX-URL>/api/v2/job_templates/272/gitlab/'
    headers = {'Authorization': 'X-Gitlab-Token: <MYTOKEN>'}
    
    response = requests.post(url, headers=headers, verify=False)
    
    print(response.status_code)
    print(response.text)

 

Labels (1)
0 Karma
Get Updates on the Splunk Community!

AI for AppInspect

We’re excited to announce two new updates to AppInspect designed to save you time and make the app approval ...

App Platform's 2025 Year in Review: A Year of Innovation, Growth, and Community

As we step into 2026, it’s the perfect moment to reflect on what an extraordinary year 2025 was for the Splunk ...

Operationalizing Entity Risk Score with Enterprise Security 8.3+

Overview Enterprise Security 8.3 introduces a powerful new feature called “Entity Risk Scoring” (ERS) for ...