It's all about the answers!

Ask a question

How to: .NET client for OSLC RM API and oAuth


Kangkan Goswami (15711621) | asked May 03 '12, 6:35 a.m.
retagged Jun 25 '12, 5:19 a.m. by Arne Bister (2.6k12832)
I am trying to get the RMCatalog through the OSLC API.

I am using c# (.Net) application and trying to get the details. But I am getting the 401 (Unauthorized) error.

I have the code here:


static void Main(string[] args)
{

WebRequest request = WebRequest.Create("https://server:9443/rm/discovery/RMCatalog");
request.Proxy = null;
request.Credentials = new NetworkCredential("User", "Pwd");

//allows for validation of SSL certificates
ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

var xmlstring = response.Headers;

//var xmlstring = response.
Console.WriteLine(xmlstring);
Console.WriteLine("Hit ENTER to see the response body...");
Console.ReadLine();

// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();

// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);

Console.WriteLine("Response stream received.");
Console.WriteLine(readStream.ReadToEnd());
Console.WriteLine("Hit ENTER to see the response body...");
Console.ReadLine();
Console.WriteLine(response.ToString());
}
catch (Exception ex)
{
Console.WriteLine("Error Occured!");
Console.WriteLine(ex.Message);
}
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}

public static bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}


This works fine when I try to get the CLM catalog at
https://server:9443/ccm/oslc/workitems/catalog


Inspecting further using Fiddler, I could find that the service is expecting oAuth authentication. I tried to find any clear documentation on this, but failed to find anything specific for .NET development.

Can somebody provide some sample code for .NET or provide me details of how one can implement such a .NET client for the OSLC RM API?

Comments
1
Akshansh Khare commented May 24 '12, 3:58 a.m. | edited Jun 10 '15, 10:50 a.m.

Hi Kangkan Goswami,

This is Akki, I am also trying to authenticate the RRC server with Oauth Authentication but no luck so far,
Can you provide me some links and/or the code that you used to authenticate the server using Oauth Authentication.

Regards
Akki


After a lot of trial and error and referring to the OSLC Workshop material (https://jazz.net/library/article/635), I could finally get the requirement list from the RM server.

However, I am yet to be able to get the values of all the attributes. While, I could GET the value for "Planned Release" attribute, others are coming blank.

Can anybody help me retrieving the attributes and their values for the requirements?
:o

6 answers



permanent link
Kangkan Goswami (15711621) | answered May 16 '12, 1:19 a.m.
I could finally find the way and could do the oAuth authentication and get the RMCatalog and the project names.

However, I am now facing issues with how to get the requirements from a selected project. Thanks to poor documentation from IBM.



I am trying to get the RMCatalog through the OSLC API.

I am using c# (.Net) application and trying to get the details. But I am getting the 401 (Unauthorized) error.

I have the code here:


static void Main(string[] args)
{

WebRequest request = WebRequest.Create("https://server:9443/rm/discovery/RMCatalog");
request.Proxy = null;
request.Credentials = new NetworkCredential("User", "Pwd");

//allows for validation of SSL certificates
ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

var xmlstring = response.Headers;

//var xmlstring = response.
Console.WriteLine(xmlstring);
Console.WriteLine("Hit ENTER to see the response body...");
Console.ReadLine();

// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();

// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);

Console.WriteLine("Response stream received.");
Console.WriteLine(readStream.ReadToEnd());
Console.WriteLine("Hit ENTER to see the response body...");
Console.ReadLine();
Console.WriteLine(response.ToString());
}
catch (Exception ex)
{
Console.WriteLine("Error Occured!");
Console.WriteLine(ex.Message);
}
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}

public static bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}


This works fine when I try to get the CLM catalog at
https://server:9443/ccm/oslc/workitems/catalog


Inspecting further using Fiddler, I could find that the service is expecting oAuth authentication. I tried to find any clear documentation on this, but failed to find anything specific for .NET development.

Can somebody provide some sample code for .NET or provide me details of how one can implement such a .NET client for the OSLC RM API?

permanent link
Kangkan Goswami (15711621) | answered May 22 '12, 4:34 a.m.
After a lot of trial and error and referring to the OSLC Workshop material (https://jazz.net/library/article/635), I could finally get the requirement list from the RM server.

However, I am yet to be able to get the values of all the attributes. While, I could GET the value for "Planned Release" attribute, others are coming blank.

Can anybody help me retrieving the attributes and their values for the requirements?

permanent link
Kangkan Goswami (15711621) | answered May 25 '12, 1:55 a.m.
edited Jan 22 '14, 8:13 a.m.
You can get the details and the code here: http://www.geekays.net/post/2012/05/25/Integrating-IBM-Jazz-oAuth-for-OSLC-API.aspx

Hi Kangkan Goswami,

This is Akki, I am also trying to authenticate the RRC server with Oauth Authentication but no luck so far,
Can you provide me some links and/or the code that you used to authenticate the server using Oauth Authentication.

Regards
Akki

:o

permanent link
Nate Decker (37814761) | answered Jan 22 '14, 8:00 a.m.

The link in the previous post is broken.

I'm encountering this problem as well. The error that I get is "The remote certificate is invalid according to the validation procedure."

I had code that authenticated successfully in 4.0.1 but no longer authenticates in 4.0.5.


Comments
Kangkan Goswami commented Jan 22 '14, 8:14 a.m.

I have updated the link. Please look for more.

I shall check on the oAuth issue for 4.0.5 sometime and let you know if I face the issue and can resolve.


permanent link
Nate Decker (37814761) | answered Jan 22 '14, 8:38 a.m.
Regarding my case, a little further digging has revealed that this is failing because our server doesn't have a valid security certificate. Other users may not have this issue.

permanent link
Marcelo Fiorito (1112) | answered Jun 10 '15, 8:15 a.m.
 HI,
Trying to integrate using the REST API but with VBScript. And I am limited to this language. Do you have any idea how to port this code to VBScript.

I am not a .NET developer but maybe you could help me to find a way or just tell me that its even worst than your tries with .NET. 

If it is not possilbe I am thinking in doing some façade in java, to be the proxy and using simple HTTP and leaving the code to authenticate behind the facade. What do you think? This way I will have to only do a simple request and have simple resposes. 

The facade could be a servlet or even another REST.

Thanks
Fiorito

Comments
Kangkan Goswami commented Jun 10 '15, 9:12 a.m.

So this is a question rather than an answer to my original question.

For questions, you should create a new post rather.

There is a standard Java implementation that you can use. Just go through the documentation. I was trying it on .NET without Java.


Marcelo Fiorito commented Jun 10 '15, 9:17 a.m.

Sorry Kangkan,

You are right. I will create a post about it.

Thanks for your time

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.