Last active
February 6, 2018 17:45
-
-
Save nbellocam/e79f0c858610912733292e546df11317 to your computer and use it in GitHub Desktop.
Calling Microsoft Graph API from an Azure Function using JavaScript - createGroup Function
This file contains 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
var request = require('request'); | |
function createGroup(token, name) { | |
return new Promise((resolve, reject) => { | |
const options = { | |
method: 'POST', | |
url: 'https://graph.microsoft.com/v1.0/groups/', | |
headers: { | |
'Authorization': 'Bearer ' + token, | |
'content-type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
"displayName": name, | |
"mailEnabled": false, | |
"securityEnabled": true | |
}) | |
}; | |
request(options, (error, response, body) => { | |
const result = JSON.parse(body); | |
if (!error && response.statusCode == 204) { | |
resolve(result.value); | |
} else { | |
reject(result); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment