Constructor of type HttpHandler not found using the Office 365 API

て烟熏妆下的殇ゞ 提交于 2019-12-01 12:59:19

问题


I recently started using the Office 365 API and can now successfully authenticate and get a token. Now I want to query the user's Exchange for meetings. To do this I run the example query from here:

    var client = new OutlookServicesClient(new Uri("https://outlook.office.com/api/2.0"), async () =>
    {
      // Since we have it locally from the Session, just return it here.
      return token;
    });

    var eventResults = await client.Me.Events.OrderByDescending(e => e.Start).Take(10).Select(e => new DisplayEvent(e.Subject, e.Start.ToString(), e.End.ToString())).ExecuteAsync();
    // query: https://outlook.office.com/api/2.0/Me/Events?$orderby=Start%%20desc&$top=10&$select=Subject,Start,End  

Unfortunately, this returns the following error (500): Server Error in '/API' Application. Constructor on type 'Microsoft.Exchange.Services.OData.Web.HttpHandler' not found.

Googling around, I found some similar errors (here and here). It seemed there was an issue with the server at that time. However, as the API is pretty mature, I assume I am doing something wrong, rather than a server error.

Edit: Testing the query on https://oauthplay.azurewebsites.net/ also results in the same error, while the example queries work.

Does someone have any idea what I am doing wrong?


回答1:


It turns out there is a typo in the .NET getting started calendar code that uses a bad URI for the constructor of the OutlookServicesClient object. That line should read:

OutlookServicesClient client = new OutlookServicesClient(
  new Uri("https://outlook.office.com/api/v2.0"),

The sample was missing the v in the URI, which was causing the error.



来源:https://stackoverflow.com/questions/34163445/constructor-of-type-httphandler-not-found-using-the-office-365-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!