[closed] Inability in RTC To Get Results From Simple Query Using REST API
![]()
Robert Heinemeyer (33●9●10)
| asked Jun 02 '14, 5:42 p.m.
closed Apr 04 '23, 5:32 a.m. by David Honey (1.8k●1●7) I recently have begun working with the REST API for RTC 4.0.2 and have had good success, including working with stored queries, have hit a wall when I attempt to do a simple query. The problem is that I run the query and it appears to have executed successfully but I don't get any results. The query I am attempting to run looks for workitems with custom field name Story ID (internal name=story_id) with a value of253892 and requests that the summaries come back in the result set. When I create and run this query in the RTC query editor I get these lines:
edited 2023-03-29 to change terminology
|
The question has been closed for the following reason: "The question is answered, right answer was accepted" by davidhoney Apr 04 '23, 5:32 a.m.
Accepted answer
![]()
I don't have RTC 4.0.2 for testing, but my RTC 4.0.6 does not return HTTP 302 for a simple query - it returns HTTP 200 instead, just like a normal request.
If the HTTP 302 is indeed the correct response, then you should add "-L" to cURL to ask it to follow the redirect. You do have a "Location" response header, so this should work. Another way to troubleshoot is to use Firefox/Firebug to verify the network traffic for such request. Robert Heinemeyer selected this answer as the correct answer
Comments Thanks, Donald. That does take care of the result set and the HTTP return is now coming back as 200; however, the result set is incorrect. I appears to contain all the work items instead of the 15 I expected. Also, I did not get the summaries as I attempted to specify. Do I have the punctuation setup right on the query specification? I attempted to use URL encoding, since that what the documentation says is required. When I look in the system output, it appears that the request resolved corrected, but I'm not sure:
> GET /ccm/oslc/contexts/Project-Identifier/workitems?oslc_cm.query=rtc_cm%
I don't have much luck with the oslc_cm.query syntax. I suggest you use the generic OSLC form (verified with RTC 4.0.6)
/ccm/oslc/contexts/<projectId>/workitems?oslc.where=rtc_ext:story_id=253892\&oslc.select=dcterms:titleNote that I escaped "&" as"\&" since I ran cURL on Linux. Also note that there is no rtc_cm:story_id. It is rtc_ext:story_id. Check the RDF/XML presentation of a particular work item to find out all the attributes. And lastly, add HTTP header "OSLC-Core-Version: 2.0" to specify the V2 to get consistent results. Ref: http://open-services.net/bin/view/Main/OSLCCoreSpecQuery Bearing in mind I'm working in Windows, this is the URL that finally worked:
|