It's all about the answers!

Ask a question

c# login to IBM CLM exception


george claud (12811) | asked May 06 '14, 7:30 a.m.
edited May 07 '14, 3:16 p.m. by Paul Slauenwhite (8.4k12)
I try to login to IBM CLM server using some c# code from

http://blog.boriskuschel.com/2012/02/c-with-visual-studio-and-rational-team.html?showComment=1399373273027#c2233627067206926337

I am stuck at the part where the code throws an exception at the last instruction:

                if ((header != null) && header.Equals("authrequired"))
                {
                    documentResponse.GetResponseStream().Flush();
                    documentResponse.Close();
                    // The server requires an authentication: Create the login form

                    HttpWebRequest formPost = (HttpWebRequest)WebRequest.Create(serverURI + "/j_security_check");
                    formPost.Method = "POST";
                    formPost.Timeout = 30000;
                    formPost.CookieContainer = request.CookieContainer;
                    formPost.ContentType = "application/x-www-form-urlencoded";
                    String output = "j_username=" + login + "&j_password=" + password;
                    Byte[] outputBuffer = Encoding.UTF8.GetBytes(output);
                    formPost.ContentLength = outputBuffer.Length;
                    Stream stream = formPost.GetRequestStream();
                    stream.Write(outputBuffer, 0, outputBuffer.Length);
                    stream.Close();

                    // Step (2): The client submits the login form
                    if (DEBUG) Console.WriteLine(">> POST " + formPost.RequestUri);
                    HttpWebResponse formResponse = (HttpWebResponse)formPost.GetResponse();
..
}
Error: The remote server returned an error: (408) Request Timeout.

I wonder whats wrong ...
Best regards
Can you please help ?

2 answers



permanent link
Sreerupa Sen (1.0k4) | answered May 08 '14, 12:50 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited May 08 '14, 12:51 p.m.
 Have you checked out https://jazz.net/library/article/601#How_VSClient_Fails_Login_Proxy_One? We've attached source code for a console application that logs into the Jazz server.

Cheers
--Rupa

Comments
george claud commented May 09 '14, 6:45 a.m.

Hi,
The code fails with an exception -_-''

System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.HttpWebRequest.GetResponse()
   at JazzConsoleApplication.Program.SendRequest(String repository, String service, SecurityContext context) in C:\Users\timo\Desktop\JazzConsoleApplication_VS2010\JazzConsoleApplication\Program.cs:li
ne 128
   at JazzConsoleApplication.Program.Main(String[] args) in C:\Users\timo\Desktop\JazzConsoleApplication_VS2010\JazzConsoleApplication\Program.cs:line 39

I put
string repository = "https://timo-pcvirtual:9443/jazz/";
and the proxy stuff i didnt changed.


george claud commented May 09 '14, 7:02 a.m.

I have modified to
"https://timo-pcvirtual:9443/jts/";
Now the code does something untill
  Console.WriteLine("Getting Project Areas...");
                SendRequest(repository, "secure/service/com.ibm.team.process.internal.common.service.IProcessRestService/allProjectAreas?", context);
Here fails with error

System.Net.WebException: The remote server returned an error: (500) Internal Server Error.


permanent link
Donald Nong (14.5k614) | answered May 07 '14, 10:47 p.m.
The HTTP code 408 is quite tricky to troubleshoot. In the case of Jazz server form based authentication, it could be that Tomcat behaves unexpectedly to the /j_security_check request. Many people met the same or similar problem before. regardless what programming languages or scripts they used. You can search "j_security_check" on jazz.net to see how others failed or succeeded

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.