cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1974
Views
0
Helpful
3
Replies

Having trouble creating organization-level webhook payload templates

NoelleNoelle
Community Member

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

Accepted Solutions

NoelleNoelle
Community Member
3 Replies 3

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

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

I am not a Cisco 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.

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

NoelleNoelle
Community Member