It's all about the answers!

Ask a question

Need help improving a REST API URI to bring back specific work item data

Richard Kissel (30617) | asked Mar 08 '17, 6:56 p.m.

CLM v5.0.2 (iFix007)

This REST API URI works to bring back my specified project work items but it brings back all of the Types and all of the tragetStateID (Status)

What I want to do is have one URI that uses the below filters and have all the Work items display that equal these values
Project Name=<projectname>
targetStateId (Staus)=Accepted
transitionDate=01/01/2017 - 03/01/2017

Why am I doing this?
I am trying to get all my custom story work items that have changed there status to "Accepted" during a specific time period 01/01/2017 - 03/01/2017 for a specific project.

I was not able to complete this as a RTC Query, which would have been the best solution. So I am trying to do this within the REST API.
I cannot seem to filter any deeper then Project name within the URI. Is there a way to add additional filters and have it bring back just that data?

I have tried many different variations of the URI and cannot even get it to give me a listing of only a specific project name and type name much less all of above listed filters.

Any help would be appreciated...Thank You

Richard Kissel commented Mar 08 '17, 7:58 p.m. | edited Mar 08 '17, 7:59 p.m.


Accepted answer

permanent link
Donald Nong (14.5k414) | answered Mar 08 '17, 7:49 p.m.
edited Mar 08 '17, 7:50 p.m.

I don't have a query that meets your exact requirement (it seems impossible), but you can try this compromised version.

?fields=workItem/workItem[projectArea/name='PHIS' AND type/id='story']/(projectArea/name|type/name|summary|stateTransitions[targetStateId='Accepted' AND transitionDate > 2017-01-01T00:00:00.000-0000 and transitionDate < 2017-03-01T00:00:00.000-0000]/(transitionDate|targetStateId|changedBy/name))
There are a few things you need to know.
1. stateTransitions is multiple-valued, so you cannot use it as a filter, but you can filter it. That's why I say it seems impossible at the beginning.
2. type/name is not queryable, and  you need to use type/id instead.
3. If you use a timezone such as +1000 in the Date value, you may need to escape it as %2B1000.
4. There are two filters shown above, one is on workItem/workItem and the other on workItem/workItem/stateTransitions.

With the above filter, you will get all the Story work items in the project PHIS, and within these work items, only the stateTransitions that meet the requirement will be shown. In other words, some work items will be shown without stateTransitions, and you will need to ignore them or further filter them out in post-processing.

Richard Kissel selected this answer as the correct answer

Richard Kissel commented Mar 08 '17, 8:02 p.m. | edited Mar 08 '17, 8:04 p.m.

I have been playing with this since I posted the question and found out about type/ID. I was able to get further if I use type/ID but I cannot get it with Project name or project/name and type/id combo. however I am able to query lower now and get what I wanted if I just use type/id as the main.

let me see what I can do with your helpful suggestion...

Thank You So Much For Your Reply

for some reason it will not let me post my URI


Your answer

Register or to post your answer.