Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

RTC Restful API autentication

The IBM RTC RESTful api gives an example of a shell script for authenticating with the server:

COOKIES=./cookies.txt

USER=my_user
PASSWORD=my_password
HOST="https://myJazzServer:9092/jazz"

curl -k -c $COOKIES "$HOST/authenticated/identity"

curl -k -L -b $COOKIES -c $COOKIES -d j_username=$USER -d j_password=$PASSWORD "$HOST/authenticated/j_security_check"


This works perfectly, however i need to authenticate with the server using c#.

So far i have the following, but it isn't working:

        CookieContainer _cookie;


public string RTC()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://myJazzServer.com:9092/jazz/authenticated/identity");
if (_cookie == null)
{
_cookie = new CookieContainer();
}
string a;
request.CookieContainer = _cookie;
using (var response = request.GetResponse())
{
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
a = sr.ReadToEnd();
}
}




byte[] data = (new ASCIIEncoding()).GetBytes("j_username=myUser&j_password=MyPass");

request = (HttpWebRequest)WebRequest.Create("https://myJazzServer.com:9092/jazz/authenticated/j_security_check");

request.Method = "POST";
request.ContentType = "text/html";
request.ContentLength = data.Length;
request.CookieContainer = _cookie;
Stream reqStream = request.GetRequestStream();
reqStream.Write(data,0,data.Length);

string b;

using (var response = request.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
b = reader.ReadToEnd();
}
}
}


Any ideas what the problem is here, is there a .net api?

0 votes


Be the first one to answer this question!

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jul 16 '10, 12:30 p.m.

Question was seen: 3,728 times

Last updated: Jul 16 '10, 12:30 p.m.

Confirmation Cancel Confirm