Can't create workitem via webrequest in RTC using C#
I'm trying to create a .NET web application integration with RTC, where I would insert new workitems using RTC change management services, as defined in this article (specifically in "Create a Change Request"). I was able to get the URL-to-be-used inside services.xml file (/oslc/contexts/_0_iN4G09EeGGMqpyZT5XdQ/workitems/) and my goal is to insert data using JSON.
My code is basically the following:
CookieContainer cookies = new CookieContainer();
As I was managed to search for in other forums, this should be enough in order to create the workitem (I have a very similar code working to update workitems using "" URL and PUT method). However, instead of create the workitem in RTC and give me some response with item's identifier, the request's response returns a huge JSON file that ends with "oslc_cm:next":"https:///oslc/contexts/_0_iN4G09EeGGMqpyZT5XdQ/workitems/%7B0%7D?oslc_cm.pageSize=50&_resultToken=_AAY50FEkEee1V4u7RUQSjA&_startIndex=50. It's a JSON representation of the XML I receive when I access /oslc/contexts/_0_iN4G09EeGGMqpyZT5XdQ/workitems/ directly from browser, like I was trying to do a simple query inside the workitem's collection (even though I'm using POST, not GET).
I also tried to use PUT method, but then I receive a 405 status code.
Does anyone have an idea of what am I missing here? My approach is wrong, even though with the same approach I'm able to update existing workitem data in RTC?
Thanks in advance.
UPDATE (20/06): I created the same code concept in Java and it works. Used "org.apache.http.client" package to execute the request parts.
|
One answer
Did you copy & paste your code around and lose track? From you code, I don't now what variable "request" should be, but you should use "documentPost" at the last stage, right?
Comments
Thiago Przybylovicz
commented Jun 20 '17, 8:27 a.m.
Hello, Donald. Thanks for your answer.
You're right, my code is bigger than that, so I tried to resume it. I edited the code to make more sense (documentPost, for example, turns into "request" inside "DoRequest" method, which I removed to write this question).
I also already changed the checking to 201 status code, but this is not the issue, since I keep receiving the status 200 and a big JSON file as if I requested a list of workitems instead of creating a workitem. |
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.