Я пытаюсь позвонить POST
на findMeetingTimes
, используя Microsoft Graph в C #
https://graph.microsoft.com/v1.0/users/{userid}/findMeetingTimes
Чтобы получить данные профиля пользователя, у меня есть следующие данные:
IUserProfile IUserAuthentication.GetProfileData(string accessToken)
{
MicrosoftUserProfile profile = new MicrosoftUserProfile();
try
{
string url = "https://graph.microsoft.com/v1.0/me";
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("Authorization", "Bearer " + accessToken);
WebRequests webReq = new WebRequests();
string response = webReq.GetRequest(url, headers);
profile = JsonConvert.DeserializeObject<MicrosoftUserProfile>(response);
}
catch (Exception)
{
throw;
}
return profile;
}
public string GetRequest(string url, IDictionary<string, string> headers)
{
string returned = "";
try
{
System.Net.WebRequest webRequest = System.Net.WebRequest.Create(url);
webRequest.Method = "GET";
if (headers.Count > 0)
{
foreach (var item in headers)
{
webRequest.Headers.Add(item.Key, item.Value);
}
}
System.Net.WebResponse resp = webRequest.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
returned = sr.ReadToEnd().Trim();
}
catch (Exception)
{
throw;
}
return returned;
}