Having trouble creating organization-level webhook payload templates

Solved
NoelleNoelle
Conversationalist

Having trouble creating organization-level webhook payload templates

I've been attempting to create an organization-level payload template, as described here: https://developer.cisco.com/meraki/api-v1/create-organization-webhooks-payload-template/

 

To preface: I've been able to create templates at the network level just fine, but would like to have the same template available across multiple networks. Not being able to use the same name for each network level template makes creating them individually undesirable, but I'm willing to do it once I've ruled out other options.

 

I have early access for the API enabled. The Python code I've successfully been using is as follows:

 
headers = {
    "X-Cisco-Meraki-API-Key": API_KEY
}

def get_organizations():
    url = f"{API_URL}/organizations"
    response = requests.get(url, headers=headers)
    response.raise_for_status()
    return response.json()

def create_org_template(organization_id😞
    sharing = json.dumps({"byNetwork":{"withAll":True,"adminsCanModify":True,"ids":[]}})
    files = [
        ('headersFile', ('customTemplate.headers.liquid', open('headers.liquid', 'rb'),'application/octet-stream')),
        ('bodyFile', ('customTemplate.body.liquid', open('body.liquid','rb'),'application/octet-stream')),
        ('name', (None, 'Jira'))
    ]
    url = '{}/organizations/{}/webhooks/payloadTemplates'.format(API_URL, organization_id)
    response = requests.post(url, files=files, headers=headers)
    print(response.json())
    response.raise_for_status()

organization_id = get_organizations()[0]["id"]
create_org_template(organization_id)
 
However, when I add the following tuple to the files list in create_org_template I get an error stating that 'sharing' must be an object:
 
('sharing', (None, sharing, 'application/json'))
 
Any ideas on how to resolve this?
 
Cheers!
1 Accepted Solution
NoelleNoelle
Conversationalist
3 Replies 3
alemabrahao
Kind of a big deal

Instead of adding the sharing parameter to the files list, try including it in the JSON payload directly.

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
NoelleNoelle
Conversationalist

I've tried that as well and unfortunately had no luck.

NoelleNoelle
Conversationalist

Solved! Solution can be found here: https://community.meraki.com/t5/Dashboard-Administration/Custom-webhook-templates-are-network-specif...

 

Apologies for the extraneous post! 

Get notified when there are additional replies to this discussion.