It's all about the answers!

Ask a question

Retrieve work items from RTC using C# code

Raja P (1527) | asked Oct 12 '17, 1:49 a.m.

Can anyone help to provide a sample C# code for retrieving list of project which are created at RTC and its associated work item through REST API using C# code.


Accepted answer

permanent link
Donald Nong (14.5k614) | answered Oct 12 '17, 4:19 a.m.

If you're really "new", I suggest you learn how to use C# to access REST API first.
(Or whatever the tutorial you feel comfortable with)

Once you get familiar with it, plug the RTC REST API calls into your application. They are not that different from any other HTTP requests. The sequence of calls that you use for a particular task is the same for all programming languages I suppose, while handling the HTTP requests and responses is different.

Ralph Schoon selected this answer as the correct answer

Raja P commented Oct 12 '17, 7:34 a.m. | edited Oct 15 '17, 1:35 p.m.
Thanks Ralph and Donald:-)
I guess the question was wrongly understood...the thing is, i am trying to get project name and its associated items by using the below.....but getting 403 forbidden error. so it would be better to provide the right URI will help me

string _serverURL = https://localhost:9443/ccm; 
string _resourceURL = "https://localhost:9443/ccm/rootservices";
_resourceURL + "/oslc/contexts/_0_iN4G09EeGGMqpyZT5XdQ/workitems/order"
CookieContainer _cookies = new CookieContainer();//create cookie container
HttpWebRequest documentGet = (HttpWebRequest)WebRequest.Create(_resourceURL);
documentGet.Method = "GET"; //method
documentGet.CookieContainer = _cookies; //set container for HttpWebRequest 
documentGet.Accept = mediatype;
documentGet.Headers.Set("OSLC-Core-Version", "3.0"); //for RTC
documentGet.Timeout = 300000;
HttpWebResponse response = requestSecureDocument(documentGet, _serverURL, username, password);

Donald Nong commented Oct 16 '17, 2:11 a.m.

Your _resourceURL variable contains an incorrect URL. Also, header "OSLC-Core-Version: 3.0" won't get you anywhere, as the current implemented OSLC version is 2.0.

One other answer

permanent link
Ralph Schoon (63.3k33646) | answered Oct 12 '17, 3:07 a.m.

I am not a C# guy, but I know our developers for the VisualStudio integration use HTTPS/REST calls. This question has also come up several times already. 

Raja P commented Oct 12 '17, 3:33 a.m. | edited Oct 12 '17, 4:07 a.m.
might be. but i am new to this area, so better to share some C# code examples or links to understand better.

Thanks Ralph for your reply:-)

Ralph Schoon commented Oct 12 '17, 3:50 a.m.

If you are new to this, you should better read the results of the google query. 

I have nothing to share. My examples are all Java, but if you are interested, you can find them here: 

they won't help you of course. 

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.