Sunday 15 March 2015

c# - Azure AD Graph API add member to group -



c# - Azure AD Graph API add member to group -

i trying add together fellow member grouping using aad graph api , maintain getting 404. similar code works me when trying grouping members. code:

string requesturl = string.format("https://graph.windows.net/{0}/groups/{1}/$linkes/members?api-version=2013-04-05", tenantname, group.objectid); string postdata = string.format("\"url\":\"https://graph.windows.net/{0}/users/{1}?api-version=2013-04-05\"", tenantname, user.objectid); httpwebrequest webrequest = webrequest.create(requesturl) httpwebrequest; webrequest.method = "post"; webrequest.headers["authorization"] = authenticationresult.createauthorizationheader(); webrequest.contenttype = "application/json"; //"application/x-www-form-urlencoded"; webrequest.host = "graph.windows.net"; webrequest.contentlength = postdata.length; byte[] bytearray = encoding.utf8.getbytes(postdata); using (stream datastream = webrequest.getrequeststream()) { datastream.write(bytearray, 0, bytearray.length); } string jsontext; var httpresponse = (httpwebresponse)webrequest.getresponse(); using (var streamreader = new streamreader(httpresponse.getresponsestream())) { jsontext = streamreader.readtoend(); }

i know there other ways same work, illustration using graph connection, prefer utilize way because should work roles well. thanks

your url seem have typo: $linkes. should $links.

c# azure azure-active-directory

No comments:

Post a Comment