Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Meraki Group Policy - Zapier Javascript Template
/*
Update the User Defined Variable strings with the necessary data between the double quotes ""
The clientMac will be pulled from the hook URL, which should be sent by the calling application, such as a Captive Portal page.
*/
// User Defined Variables
var apiKey = ""; // The Meraki API key
var shard = "api"; // The Meraki Shard. This can be found in the Dashboard URL (n143).. https://n143.meraki.com/~
var netId = ""; // The Meraki Network ID
var policyId = ""; // The Meraki Group Policy ID number
// #####################################
// Variables pulled from hook parameters
var clientMac = inputData.clientMac;
// API Call
var headers = {
'X-Cisco-Meraki-API-Key': apiKey,
'Accept': 'application/json',
'Content-Type': 'application/json'
};
var urlPolicy = "https://"+shard+".meraki.com/api/v0/networks/"+netId+"/clients/"+clientMac+"/policy?timespan=84000";
// Assign Policy via Meraki API
fetch(urlPolicy, {
method: 'PUT',
headers: headers,
body: JSON.stringify({
"devicePolicy":"group",
"groupPolicyId":policyId
})
})
.then(function(res) {
console.log("Meraki res: "+res);
return res.json();
})
.then(function(json) {
callback(null, json);
})
.catch(callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.