Filtering by included information

19 views
Skip to first unread message

Brian Stevens

unread,
Oct 7, 2016, 12:42:19 PM10/7/16
to DevTargetProcess
Greetings,

I have been trying to figure out how to limit the results directly from the API.  For a given story, I am returning the Assigned Effort, but I really only want to have the effort from the QA Engineer.  I haven't been able to figure out how to limit the results to just that.  Does anyone have any tips on how I can accomplish this in my API call?  Or is it even possible.  I can find the information in C# just fine, but if I can figure out a way to filter it to just want I need, I'd rather do that.

Thanks!


/api/v1/UserStories/14049?include=[AssignedEfforts[Effort,Role]]


<UserStory ResourceType="UserStory" Id="14049">
    <AssignedEfforts>
        <AssignedEffort Id="21800">
            <Effort>3.0000</Effort>
            <Role Id="1" Name="Developer" />
        </AssignedEffort>
        <AssignedEffort Id="21801">
            <Effort>0.0000</Effort>
            <Role Id="7" Name="Product Owner" />
        </AssignedEffort>
        <AssignedEffort Id="21802">
            <Effort>5.0000</Effort>
            <Role Id="9" Name="QA Engineer" />
        </AssignedEffort>
    </AssignedEfforts>
</UserStory>

Dmitry Tsarevich

unread,
Oct 8, 2016, 4:50:15 AM10/8/16
to DevTargetProcess
Hello!

First, open api/v1/UserStories/meta to see Userstory metadata.

Userstory has a AssignedEfforts resource collection you already queried for. Also, notice Userstory is derived from Assignable.


Second, open AssignedEffort metadata to see AssignedEffort metadata.

AssignableEffort
 has a reference to Assignable. Looks like it is back link to Userstory in our case.
Quick check api/v1/AssignedEfforts/21802?include=[Assignable[Id,Name,EntityType[Name]]] shows Assignable is our Userstory.


Third, write the query to get needed info for AssignedEffort of 'QA Engineer' from Userstory (Assignable with Id = 14049):

/api/v1/AssignedEfforts?where=(Assignable.Id eq 14049) and (Role.Name eq 'QA Engineer') 

or less explicit, but potentially faster one:

/api/v1/AssignedEfforts?where=(Assignable.Id eq 14049) and (Role.Id eq QA_ENGINEER_ROLE_ID

Useful links:
  1. API metadata. Also available as /api/v1/index/meta for your TargetProcess instance.
  2. TargetProcess REST API usage guide. Especially, response format reference.

Hope, this helps!

Brian Stevens

unread,
Oct 10, 2016, 6:06:38 PM10/10/16
to DevTargetProcess
This helped tremendously! I was initially close with some of the other things I was trying, but your explanation really opened up how all the different parts work together.  I was able to expand this further to look across an entire sprint and still just find the information that I want.

Thank you for your help!
Reply all
Reply to author
Forward
0 new messages