Udostępnij za pośrednictwem


Office.js web add-in throws HTTP 401 Unauthorized

One of my dev customer, created Outlook Web add-in (using Office.js/JavaScript) and tried calling EWS call (mailbox.makeEWSRequestAsync method). It throws HTTP error 401 for mailbox.makeEWSRequsetAsync() method. They noticed the error or behaviour when they tested with Outlook on the Web and Outlook Web Access for devices.

  • The API call throws, the following HTTP error: “The remote server returned an error: (401) Unauthorized
  • We looked at the add-in code, we see that they’re calling the above method more times (5+ times) – as they’re crossing the limit that we set with Office.js. In the above scenario, the method’s limit is set as 3. Refer the documentation and check the Table # 4. So there is a limit of the number of simultaneous asynchronous calls at any one time, as browsers allow only a limited number of asynchronous calls to servers. 
  • By limiting the number of times the API’s getting called, helped them moving forward. Please be aware that it’s Asynchronous calls that you’re making from this API call – so you need to understand the set/get the limits for JavaScript API for Office while using them.
  • It’s not just the above API call where the limit/cap exists, check in Table # 4 (refer “asynchronous calls” feature in it).

Limits for JavaScript API

Hope this helps.