Created
October 17, 2017 13:10
-
-
Save dexterlabora/a2486e0e600eecdfd4a9444a40c99060 to your computer and use it in GitHub Desktop.
JavaScript code snip to add a Meraki client to a Group Policy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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