我正在尝试创建一个订阅,以使用Microsoft Graph API通过推送通知获取Outlook电子邮件@提及。我正在使用this documentation作为参考/
我在portal.azure.com中创建了一个应用,并在“ Microsoft Graph” API下提供了“读取用户邮件”所需的权限,并且管理员通过Microsoft Demo租户同意了该请求。但是我仍然无法订阅Microsoft Graph Push Notification REST API,并且出现400 Bad Request
错误。
我还尝试在Microsoft Graph API下向portal.azure.com中的应用程序授予所有权限,并且管理员再次通过我的Microsoft演示租户同意了该应用程序,但是我仍然收到相同的400
错误请求错误。
我正在使用以下代码创建订阅:
private static void Subscribe(AuthenticationHeaderValue authHeader)
{
using(HttpClient _httpClient = new HttpClient())
{
_httpClient.BaseAddress = new Uri("https://graph.microsoft.com");
_httpClient.DefaultRequestHeaders.Accept.Clear();
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));
_httpClient.DefaultRequestHeaders.Authorization = authHeader;
// connect to the REST endpoint to subscribe
var json = @"{
'changetype':'created,updated',
'notificationurl': 'http://requestbin.fullcontact.com/two54stw/',
'resource': 'me/mailfolder(\'Inbox\')/messages',
'clientstate': 'secretclientvalue'
}";
HttpContent contentPost = new StringContent(json.ToString(), Encoding.UTF8, "application/json");
HttpResponseMessage subscribe = _httpClient.PostAsync($"v1.0/subscriptions", contentPost).Result;
Console.WriteLine("New subscription created!");
}
}
有人解决过类似的问题,以创建“推送通知订阅”来获取Outlook电子邮件吗?