Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

[closed] Inability in RTC To Get Results From Simple Query Using REST API

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:

Development Implementation
TP 16893: GD-54 Generate Underwriting Letter HSU10 Uprate MPD
Architect Review
Clarification-16893:US GD-54 Generate Underwriting letter HSU10 Uprate MPD
Execute Test Package Unit Tests
16893: US GD-54 Generate Underwriting Letter HSU10 Uprate MPD
Conversion Review
Batch Job Review
Create JUnit Tests
Development Review
Pit Testing
Code Review
QA Execution Team Review
DCS Review
Sit Testing


Below is my attempt to implement this query using the REST API through CURL.  These statement were contained in a .bat file and run through an DOS command line box within windows. For the URL

encoding, the %s are doubled, since the DOS box treats these as special characters.  Also, the URL is quoted because CURL has a problem with the & character.

curl -k -c C:\Perl\site\bin\cookie.txt https://Server-Name/jts/authenticated/identity -o quiet.txt
curl -k -L -b C:\Perl\site\bin\cookie.txt -c C:\Perl\site\bin\cookie.txt -d j_username=USER -d j_password=PASSWORD https://Server-Name/jts/authenticated/j_security_check -o quiet.txt
curl -D - -k -v -b C:\Perl\site\bin\cookie.txt  -o "query_dump.xml" -H "Accept: application/rdf+xml" "https://Server-Name/ccm/oslc/contexts/Project-Identifier/workitems?oslc_cm.query=rtc_cm%%3Astory_id%%3D%%22253892%%22&oslc_cm.properties=dc%%3Atitle" > out.txt

This is the output I get:

C:\Perl_Scripts\Importer>curl -k -c C:\Perl\site\bin\cookie.txt https://Server-
Name/jts/authenticated/identity -o quiet.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1910  100  1910    0     0   5552      0 --:--:-- --:--:-- --:--:--  5552

C:\Perl_Scripts\Importer>curl -k -L -b C:\Perl\site\bin\cookie.txt -c C:\Perl\si
te\bin\cookie.txt -d j_username=USER -d j_password=PASSWORD https://rtc-web1.
ent.rt.csaa.com/jts/authenticated/j_security_check -o quiet.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    38    0     0  100    38      0     52 --:--:-- --:--:-- --:--:--    52
100    99  100    99    0     0    124      0 --:--:-- --:--:-- --:--:--   124

C:\Perl_Scripts\Importer>curl -D - -k -v -b C:\Perl\site\bin\cookie.txt  -o "que
ry_dump.xml" -H "Accept: application/rdf+xml" "https://Server-Name/
ccm/oslc/contexts/Project-Identifier/workitems?oslc_cm.query=rtc_cm%3Astory
_id%3D%22253892%22&oslc_cm.properties=dc%3Atitle"  1>out.txt
Adding handle: conn: 0x692cb0
Adding handle: send: 0
Adding handle: recv: 0
Curl_addHandleToPipeline: length: 1
- Conn 0 (0x692cb0) send_pipe: 1, recv_pipe: 0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

About to connect() to Server-Name port XXX (#0)
   Trying XXX.XX.XXX.XX...
Connected to Server-Name (XXX.XX.XXX.XX) port XXX (#0)
SSLv3, TLS handshake, Client hello (1):
} [data not shown]
SSLv3, TLS handshake, Server hello (2):
{ [data not shown]
SSLv3, TLS handshake, CERT (11):
{ [data not shown]
SSLv3, TLS handshake, Server key exchange (12):
{ [data not shown]
SSLv3, TLS handshake, Server finished (14):
{ [data not shown]
SSLv3, TLS handshake, Client key exchange (16):
} [data not shown]
SSLv3, TLS change cipher, Client hello (1):
} [data not shown]
SSLv3, TLS handshake, Finished (20):
} [data not shown]
SSLv3, TLS change cipher, Client hello (1):
{ [data not shown]
SSLv3, TLS handshake, Finished (20):
{ [data not shown]

SSL SERVER CERTIFICATE INFO

> GET /ccm/oslc/contexts/Project-Identifier/workitems?oslc_cm.query=rtc_cm%
3Astory_id%3D%22253892%22&oslc_cm.properties=dc%3Atitle HTTP/1.1
> User-Agent: curl/7.30.0
> Host: Server-Name
> Cookie: JSESSIONIDSSO=0DDECC0ED22FD09D71A3E751E3CEB76A
> Accept: application/rdf+xml
>
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0<
HTTP/1.1 302 Found
Server Apache-Coyote/1.1 is not deny list

< Server: Apache-Coyote/1.1
< Cache-Control: private, max-age=0, must-revalidate
< Expires: Mon, 02 Jun 2014 20:58:26 GMT
Added cookie JSESSIONID="CC266B24D87C64850C0D150534E7E8C6" for domain rtc-web1
.ent.rt.csaa.com, path /ccm/, expire 0
< Set-Cookie: JSESSIONID=CC266B24D87C64850C0D150534E7E8C6; Path=/ccm/; Secure; H
ttpOnly
< Location: https://Server-Name/ccm/oslc/contexts/_m17BMFjsEeGuY6fU
NqmDsQ/workitems?oslc.pageSize=50&_resultToken=_o3clceqYEeOU8JSAENtmAw&_startInd
ex=0
< Content-Length: 0
< Date: Mon, 02 Jun 2014 20:58:25 GMT
<
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
* Connection #0 to host Server-Name left intact


It appears to work correctly (HTTP/1.1 302 Found), but there is no output to either query_dump.xml or out.txt or to stdout.

Can anyone provide any help on this?

Thanks,


edited 2023-03-29 to change terminology

0 votes


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

Permanent link
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

3 votes

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%
3Astory_id%3D%22253892%22&oslc_cm.properties=dc%3Atitle HTTP/1.1

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:title
Note 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:

"https://Server-Name/ccm/oslc/contexts/_m17BMFjsEeGuY6fUNqmDsQ/workitems?oslc.where=rtc_cm:story_id=\"253892\"&oslc.select=dcterms:title"

Note that the quotes around the whole thing where required to get it to accept the oslc.select.  Also, I did use the "OSLC-Core-Version: 2.0" header.

Thanks again for all the help, Donald.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937

Question asked: Jun 02 '14, 5:42 p.m.

Question was seen: 5,398 times

Last updated: Apr 04 '23, 5:32 a.m.

Confirmation Cancel Confirm