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

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

$
0
0

Hello,

I am trying to create appointment from Exchange Web Service, If I am trying to login to exchange server from URL then its working and allowing me to login to my exchange server but if I am trying to connect from my C# application then I am getting this error "The request failed. The remote server returned an error: (401) Unauthorized."

My current code is as below:

ExchangeService service =newExchangeService();
service.Credentials=newWebCredentials("XXX\username","pwd","exchange.domain.com");

service.Url=newUri("https://exchange.domain.com/EWS/Exchange.asmx");Appointment appointment =newAppointment(service);
appointment.Subject="Status Meeting";
appointment.Body="The purpose of this meeting is to discuss status.";
appointment.Start=newDateTime(2017,1,30,9,0,0);
appointment.End= appointment.Start.AddHours(2);
appointment.Location="Conf Room";
appointment.RequiredAttendees.Add("xyz@domain.com");
appointment.Save(SendInvitationsMode.SendToNone);

If I am trying to login from url and its also working fine.
exchange.domain.com
username - XXX\username
pwd - "pwd"

Also I have tried to login web service from URL and its work for me.

Please anyone suggest what's the wrong with C# code and how I can make working it.

Thanks.


Viewing all articles
Browse latest Browse all 7132

Trending Articles



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