Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

EWS - The remote server returned an error: (401) Unauthorized

$
0
0

I’m developing client application, which connects to a mailbox then reads/parses messages and updates client database. The company uses Office 365. I’m using Managed APIs :

var _service =newExchangeService(ExchangeVersion.Exchange2010_SP1);

               _service.TraceEnabled = true;

               _service.Credentials = new System.Net.NetworkCredential("user_id","user_pwd");

               AutodiscoverService ads =newAutodiscoverService();

               ads.EnableScpLookup = false;

               ads.RedirectionUrlValidationCallback = delegate {returntrue; };

               GetUserSettingsResponse grResp = ads.GetUserSettings("user_id@domain_name.com",UserSettingName.InternalEwsUrl);

               Uri casURI =newUri(grResp.Settings[UserSettingName.ExternalEwsUrl].ToString());

               _service.Url = casURI;

Line starting “ads.GetUserSettings..” gives the error “The remote server returned an error: (401) Unauthorized…” even though I logged as the Exchange Admin...


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>