2

I have an application that uses the outlook REST API for creating events on the user's calendar. The creation of the event works perfectly, but once I tried to to exactly as this post indicates, I get 405 Method Not Allowed.

the error details are as follow:

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

here's a part of my code:

    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);

I have the user token sotred on the "token" variable, as well as the outlook event Id on the "meeting.OutlookEventId" variable.

Any ideas?

Thank you very much!

4

1 回答 1

4

我觉得自己像个彻头彻尾的傻瓜...

当此请求需要 PATCH 时,我正在发送 POST

我刚换

HttpMethod.Post

为了

new HttpMethod("PATCH")
于 2015-05-27T17:52:45.703 回答