i am open this URL(
http://id.skootit.com/WorkspaceServi...d.skootit.com/) directly in browser with enter credential then its open and show xml data. but if i used this url in code means i send Requset and post data on server then i am getting Error(The remote server returned an error: (401) Unauthorized.) here i used same credentials.
I send request by this code.
Expand|Select|Wrap|Line Numbers
- HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://id.skootit.com/WorkspaceService/ListInvitations");
- myHttpWebRequest.Method = "POST";
- string postData = "?actor=http://goku.id.skootit.com/";
- byte[] byte1 = Encoding.UTF8.GetBytes(postData);
- myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
- myHttpWebRequest.ContentLength = byte1.Length;
- myHttpWebRequest.Credentials = new NetworkCredential("http://goku.id.skootit.com/", "topia1", "id.skootit");
- Stream newStream = myHttpWebRequest.GetRequestStream();
- newStream.Write(byte1, 0, byte1.Length);
- newStream.Close();
- //(on this line i m getting error.)
- WebResponse response = myHttpWebRequest.GetResponse();
- newStream = response.GetResponseStream();
- StreamReader reader = new StreamReader(newStream);
- string responseFromServer = reader.ReadToEnd();
- Console.WriteLine(responseFromServer);
- reader.Close();
- newStream.Close();
- response.Close();
System.Net.WebException was unhandled
Message="The remote server returned an error: (401) Unauthorized."
Source="System"
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at ConsoleApplication2.Program.Main(String[] args) in C:\Documents and Settings\nidhi\My Documents\Visual Studio 2008\Projects\ConsoleApplication2\ConsoleApplicati on2\Program.cs:line 71
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
please help me how to solve this error??