HttpHandler type constructor not found using Office 365 API

I recently started using the Office 365 API and now I can successfully authenticate and receive a token. Now I want to request an Exchange user for meetings. To do this, I run an example request 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.

Google, I found some similar errors ( here and here ), It seems that at that time there was a problem with the server. However, since the API is quite mature, I assume that I am doing something wrong, and not a server error.

Change . Testing the request at https://oauthplay.azurewebsites.net/ also leads to the same error, while sample requests work.

Does anyone know what I'm doing wrong?

0
source share
1 answer

It turns out that .NET runs calendar code that uses a bad URI for the constructor OutlookServicesClientobject. This line should read:

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

There was no pattern in the URI vthat caused the error.

+2
source

Source: https://habr.com/ru/post/1618974/


All Articles