How can I set a team picture programmatically using Microsoft graph API?

邮差的信 提交于 2020-07-22 05:11:22

问题


How can I set a team picture using Microsoft graph API? Is there a way while provisioning Microsoft team using the automated way[Using Microsoft Graph Team API] we can set team picture icon or upload team picture icon using Microsoft graph API.


回答1:


Yes you can do that through the group profile photo endpoint. Each Microsoft team relies on a unified group underneath so all operations done on a group will reflect on the team. Here is the documentation of the endpoint




回答2:


Set Team Icon can be done by the below lines of code using Patch Request with custom Content-type using plaint HttpRequest in C#

HttpClient _httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Valid_accessToken");      
string graphUploadPhotoEndPoint = $"{GRAPH_ENDPOINT_1_0}/groups/{TeamsId or GroupId}/photo/$value";

var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(HttpMethod.Put, graphUploadPhotoEndPoint);

Stream stream = System.IO.File.OpenRead($"{IconPath}");
HttpContent content = new StreamContent(IconeContent);
request.Content = content;
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var response = _httpClient.SendAsync(request).Result;
string sitesRootResponse = await response.Content.ReadAsStringAsync();


来源:https://stackoverflow.com/questions/58569252/how-can-i-set-a-team-picture-programmatically-using-microsoft-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!