title: Error 401 when trying to get free/busy slots from shared Outlook calendars using Microsoft Graph Java SDK
body: <p>I created two fresh Outlook accounts and shared one's Outlook calendar with the other. Then I tried getting the shared calendar free/busy slots by using Graph API Java SDK:</p>
  
  <pre class="lang-java prettyprint-override"><code> final String accessToken = resolveAccessToken(refreshToken);
      final IGraphServiceClient graphServiceClient = client.getClient(accessToken);
  
      ICalendarGetScheduleCollectionPage iCalendarGetScheduleCollectionPage = null;
  
      final DateTimeTimeZone startTime = new DateTimeTimeZone();
      startTime.dateTime = RFC339Utils.fromInstant(timeFrame.getStartAt());
  
      final DateTimeTimeZone endTime = new DateTimeTimeZone();
      endTime.dateTime = RFC339Utils.fromInstant(timeFrame.getEndAt());
  
      ICalendarGetScheduleCollectionPage iCalendarGetScheduleCollectionNextPage =
          graphServiceClient
              .me()
              .calendar()
              .getSchedule(emails, endTime, startTime, availabilityViewInterval)
              .buildRequest()
              .post();
  </code></pre>
  
  <p>For this request I received an empty response body with a nested inner exception: </p>
  
  <pre><code>System.Net.WebException: The request failed with HTTP status 401: Unauthorized.\r\n   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)\r\n   at System.Web.Services.Protocols.SoapHttpClientProtocol.EndInvoke(IAsyncResult asyncResult)\r\n   at Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.Service.EndGetUserAvailability(IAsyncResult asyncResult)\r\n   at Microsoft.Exchange.InfoWorker.Common.Availability.FreeBusyApplication.EndProxyWebRequest(ProxyWebRequest proxyWebRequest, QueryList queryList, IService service, IAsyncResult asyncResult)\r\n   at Microsoft.Exchange.InfoWorker.Common.Availability.ProxyWebRequest.EndInvoke(IAsyncResult asyncResult)\r\n   at Microsoft.Exchange.InfoWorker.Common.Availability.AsyncWebRequest.EndInvokeWithErrorHandling()"
  </code></pre>
  
  <p>Then I tried performing the following request</p>
  
  <pre><code>POST https://graph.microsoft.com/v1.0/me/calendar/getSchedule
  </code></pre>
  
  <p>with request body </p>
  
  <pre><code>{
    "schedules": [
      "joseph.baker.doodle@outlook.com"
    ],
    "startTime": {
      "dateTime": "2019-10-24T09:00:00",
      "timeZone": "Pacific Standard Time"
    },
    "endTime": {
      "dateTime": "2019-10-30T18:00:00",
      "timeZone": "Pacific Standard Time"
    },
    "availabilityViewInterval": 60
  }
  </code></pre>
  
  <p>cURL command</p>
  
  <pre><code>curl 'https://graph.microsoft.com/v1.0/me/calendar/getSchedule' -H 'Connection: keep-alive' -H 'Accept: application/json, text/plain, */*' -H 'Origin: https://developer.microsoft.com' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36' -H 'SdkVersion: GraphExplorer/3.0' -H 'Authorization: Bearer {insert access token here}' -H 'Content-type: application/json' -H 'Sec-Fetch-Site: same-site' -H 'Sec-Fetch-Mode: cors' -H 'Referer: https://developer.microsoft.com/en-us/graph/graph-explorer' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-GB,en;q=0.9,en-US;q=0.8,sr;q=0.7,hr;q=0.6' --data-binary $'{\n  "schedules": [\n    "joseph.baker.doodle@outlook.com"\n  ],\n  "startTime": {\n    "dateTime": "2019-10-24T09:00:00",\n    "timeZone": "Pacific Standard Time"\n  },\n  "endTime": {\n    "dateTime": "2019-10-30T18:00:00",\n    "timeZone": "Pacific Standard Time"\n  },\n  "availabilityViewInterval": 60\n}' --compressed
  </code></pre>
  
  <p>and I got this response</p>
  
  <pre><code>{
      "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.scheduleInformation)",
      "value": [
          {
              "scheduleId": "joseph.baker.doodle@outlook.com",
              "error": {
                  "message": "Proxy web request failed. , inner exception: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.\r\n   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)\r\n   at System.Web.Services.Protocols.SoapHttpClientProtocol.EndInvoke(IAsyncResult asyncResult)\r\n   at Microsoft.Exchange.InfoWorker.Common.Availability.Proxy.Service.EndGetUserAvailability(IAsyncResult asyncResult)\r\n   at Microsoft.Exchange.InfoWorker.Common.Availability.FreeBusyApplication.EndProxyWebRequest(ProxyWebRequest proxyWebRequest, QueryList queryList, IService service, IAsyncResult asyncResult)\r\n   at Microsoft.Exchange.InfoWorker.Common.Availability.ProxyWebRequest.EndInvoke(IAsyncResult asyncResult)\r\n   at Microsoft.Exchange.InfoWorker.Common.Availability.AsyncWebRequest.EndInvokeWithErrorHandling()",
                  "responseCode": "ErrorProxyRequestProcessingFailed"
              }
          }
      ]
  }
  </code></pre>
  
  <p>Is this a bug on Outlook side? I would appreciate any help.</p>