Skip to content

Instantly share code, notes, and snippets.

@dexterlabora
Created October 17, 2017 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dexterlabora/a2486e0e600eecdfd4a9444a40c99060 to your computer and use it in GitHub Desktop.
Save dexterlabora/a2486e0e600eecdfd4a9444a40c99060 to your computer and use it in GitHub Desktop.
JavaScript code snip to add a Meraki client to a Group Policy.
// Set Variables
var apiKey = "";
var shard = "";
var netId = "";
var policyId = "";
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