簡體   English   中英

使用Outlook Rest API的更新事件因方法不允許而失敗

[英]Update event with outlook rest api fails with Method Not Allowed

我有一個使用Outlook REST API在用戶日歷上創建事件的應用程序。 創建該事件的過程非常完美,但是一旦按照本文的指示進行操作,就得到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);

我在“ token”變量上有用戶令牌,在“ meeting.OutlookEventId”變量上有Outlook事件ID。

有任何想法嗎?

非常感謝你!

我覺得自己像個傻瓜...

當此請求需要PATCH時,我正在發送POST

我剛更換

HttpMethod.Post

對於

new HttpMethod("PATCH")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM