Outlook AddIn Mobile Issue - not working in mobile whereas same code works for Desktop and web client

半世苍凉 提交于 2019-12-11 16:56:28

问题


I have the bellow error in Microsoft exchange server service, but only on mobiles as same code works for Desktops and web.

ERROR MESSAGE:

System.Net.WebException: The remote server returned an error: (401) Unauthorized.

at System.Net.HttpWebRequest.GetResponse() at Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse() in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\EwsHttpWebRequest.cs:line 113 at

Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) in \REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\Requests\ServiceRequestBase.cs: line 821The request failed.

The remote server returned an error: (401) Unauthorized.

CODE SNIPPET:

// Create an ExchangeService object, set the credentials and the EWS URL.
ExchangeService exchangeService = new ExchangeService();
exchangeService.Credentials = new OAuthCredentials(attachmentToken);
exchangeService.Url = new Uri(ewsUrl);
exchangeService.UseDefaultCredentials = true;
exchangeService.PreAuthenticate = true;
try
{
var getAttachmentsResponse =exchangeService.GetAttachments(attachmentIds.ToArray(),null,new PropertySet(BasePropertySet.FirstClassProperties,ItemSchema.MimeContent));
}
catch (Exception ex)
{
var errMsg = ex.Message;
var errInnerException = ex.InnerException;
message += "Inner Exception :" + errInnerException;
}

来源:https://stackoverflow.com/questions/55115449/outlook-addin-mobile-issue-not-working-in-mobile-whereas-same-code-works-for-d

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