How to: .NET client for OSLC RM API and oAuth
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:
This works fine when I try to get the CLM catalog at
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?
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?
6 answers
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.
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 athttps://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?
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?
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?
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
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.
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
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.
Sorry Kangkan,
You are right. I will create a post about it.
Thanks for your time
Comments
Akshansh Khare
Jun 10 '15, 10:50 a.m.Hi Kangkan Goswami,
:oThis 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
1 vote