Calendar 使用MS Graph自动接受用户的会议邀请
我正在尝试使用对Calendar.Read、Calendar.ReadWrite具有管理员权限的服务负责人接受会议,以便受邀用户不必接受会议。但我一直在获取未找到的对象错误 高级代码:Calendar 使用MS Graph自动接受用户的会议邀请,calendar,microsoft-graph-api,microsoft-graph-calendar,Calendar,Microsoft Graph Api,Microsoft Graph Calendar,我正在尝试使用对Calendar.Read、Calendar.ReadWrite具有管理员权限的服务负责人接受会议,以便受邀用户不必接受会议。但我一直在获取未找到的对象错误 高级代码: using Microsoft.Graph; using Newtonsoft.Json; using System; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; using (v
using Microsoft.Graph;
using Newtonsoft.Json;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using (var httpClient = new HttpClient())
{
string resultjson = "";
string eventId = "Aaakndf8ianffnddd=";
string attendeeUPN = "john@test.com"; //user who has the meeting event
string authToken = GetToken(); //accessToken is generated using servicePrincipal which has Admin Consent on Calendar.Read, Calendars.ReadWrite permissions both on Delegated and Application Type
EventAcceptRequestBody eventAcceptRequestBody = new EventAcceptRequestBody();
eventAcceptRequestBody.SendResponse = false;
string jsonBody = JsonConvert.SerializeObject(eventAcceptRequestBody);
string url = $"https://graph.microsoft.com/v1.0/users/{attendeeUPN}/calendar/events/{eventId}/accept"
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken);
var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
HttpResponseMessage response = httpClient.PostAsync(url, content).Result;
resultjson = await response.Content.ReadAsStringAsync();
return resultjson;
}
错误:
{“error”:{“code”:“ErrorItemNotFound”,“message”:“在存储中找不到指定的对象。”}
有人知道我为什么老是犯这样的错误吗?
谢谢
Sanjeev您可以尝试提出相同的请求,或者尝试通过?这将有助于确认事件存在且ID正确。好的,如果您得到的是404,那么API调用工作正常,但不存在具有该ID的事件。该事件确实存在,我也在graph explorer中尝试过。我没有包含在上面的代码中,但首先我调用RESTAPI来创建事件,并获取eventId并调用“accept”来接受会议,所以我知道事件确实存在。