使用 outlook rest api 更新事件失败,方法不允许

Update event with outlook rest api fails with Method Not Allowed

我有一个使用 outlook REST API 在用户日历上创建事件的应用程序。事件的创建工作完美,但是一旦我尝试完全按照 this post 指示,我得到 405 Method Not Allowed.

错误详情如下:

{"error":{"code":"ErrorInvalidRequest","message":"The OData request is not supported."}}

这是我的部分代码:

    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, new Uri("https://outlook.office365.com/api/v1.0/me/events/"+meeting.OutlookEventId));

    var auth = "Bearer " + token;
    request.Headers.Add("Accept", "application/json");
    request.Headers.Add("Authorization", auth);

    var converters = new List<JsonConverter>();
    converters.Add(new MyStringEnumConverter());

    var createResponse = @"{
      'Location': {
        'DisplayName': 'Your office'
      }
    }";

    request.Content = new StringContent(createResponse);
    request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

    var response = await client.SendAsync(request);

我将用户令牌存储在“令牌”变量中,并将 outlook 事件 ID 存储在“meeting.OutlookEventId”变量中。

有什么想法吗?

非常感谢!

我觉得自己像个傻瓜...

当此请求需要 PATCH

时,我正在发送 POST

我刚换了

HttpMethod.Post

为了

new HttpMethod("PATCH")