Constructor of type HttpHandler not found using th

2020-03-31 07:11发布

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条回答
唯我独甜
2楼-- · 2020-03-31 08:06

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.

查看更多
登录 后发表回答