Retrieving work items with custom attributes via REST was RE: How to retrieve Stories and Defects in one query using Java SDK

122 views
Skip to first unread message

Saxon, Will

unread,
Apr 10, 2012, 11:45:08 AM4/10/12
to version...@googlegroups.com
Ian,

I'm aware of this, it's what we're doing right now. The question is whether we can get the custom fields for both Stories and Defects (and Primary Work Items) in one query.

So if I issue something like:

$url/PrimaryWorkitem?sel=StandardProperty,Custom_Story1,Custom_Defect2&where=Custom_PWI_ExportFlag='yes'

Where Custom_Story1 is specific to Stories, Custom_Defect2 is specific to Defects and Custom_PWI_ExportFlag is specific to PrimaryWorkitems, I get an error. I have to do this instead:

$url/PrimaryWorkitem?sel=StandardProperty&where=Custom_PWI_ExportFlag='yes'

Then for each item:

$url/Story/$id?sel=Custom_Story1 (if it's a Story)
$url/Defect/$id?sel=Custom_Defect1 (if it's a Defect)

Then combine the results from the original query with the individual results.

What I'm wondering is whether there is a way to issue 1 query for Workitem(s) and get it/them - with PWI- and Story- or Defect-specific custom fields - in one go.

Sorry to hijack this thread, I should have posted separately.

-Will

> -----Original Message-----
> From: version...@googlegroups.com [mailto:versionone-
> d...@googlegroups.com] On Behalf Of ibuchanan
> Sent: Tuesday, April 10, 2012 11:33 AM
> To: version...@googlegroups.com
> Subject: Re: How to retrieve Stories and Defects in one query using Java
> SDK
>
> Will,
>
> I understand better now. You can get custom fields that are unique to each
> Story and Defect using attribute selection syntax. For example:
> https://www14.v1host.com/v1sdktesting/rest-
> 1.v1/Data/PrimaryWorkitem?page=5,0&sel=Name,Number,AssetType,Story.Value,D
> efect.Resolution <https://www14.v1host.com/v1sdktesting/rest-
> 1.v1/Data/PrimaryWorkitem?page=5,0&sel=Name,Number,AssetType,Story.Value,D
> efect.Resolution>
> username: admin
> password: admin
>
> If you check meta, you'll notice Value is unique to Story and Resolution
> is unique to Defect.
>
> Hope that helps.
>
> Ian
>
>
> On Tuesday, April 10, 2012 10:54:25 AM UTC-4, Saxon, Will wrote:
>
> We have a legacy defect tracking system which we want to auto-
> populate w/ V1 Stories and Defects. There are item-specific required
> attributes which match up with the custom fields in V1. So ideally, we'd
> get all the PWIs ready for export, loop through each one, build the
> corresponding legacy object, submit that and then update the V1 item to
> clear the export flag. Instead we're having to get all the PWIs, issue
> separate queries to get the Story- or Defect-specific attributes, then
> build/submit/update.
>
> This is just one example. There has been discussion about dropping
> the legacy system in favor of a 100% V1-based workflow, but anytime we
> want to work with a backlog item that has Story- or Defect-specific fields
> we have to issue two queries. Since we're using the hosted solution, the
> added latency is a concern for us.
>
> -Will
>
> > -----Original Message-----
> > From: version...@googlegroups.com <mailto:versionone-
> d...@googlegroups.com> [mailto:versionone-
> > d...@googlegroups.com] On Behalf Of ibuchanan
> > Sent: Tuesday, April 10, 2012 10:23 AM
> > To: version...@googlegroups.com <mailto:versionone-
> d...@googlegroups.com>
> > Subject: Re: How to retrieve Stories and Defects in one query
> using Java
> > SDK
> >
> > Will,
> >
> > You might be able to use downcasting. See:
> >
> http://community.versionone.com/sdk/Documentation/DataAPI.aspx#section.att
> <http://community.versionone.com/sdk/Documentation/DataAPI.aspx#section.at
> t>
> > ribute.syntax
> >
> > That said, I'm not sure it will let you select on both Story- and
> Defect-
> > specific fields at once. You might need to do something with
> Custom
> > Columns. Can you explain a little more about why you want
> different
> > attributes to come back in the same query?
> >
> > Ian
> >
> >
> > On Tuesday, April 10, 2012 9:48:43 AM UTC-4, Saxon, Will wrote:
> >
> > I have a followup question to this, because I am working
> on a
> > similar problem.
> >
> > I am not using the Java SDK but rather interfacing
> directly w/ the
> > API over HTTP. I have custom fields defined on PrimaryWorkitems,
> Stories
> > and Defects. If I want to get all the Stories and Defects with a
> > particular PWI custom value - e.g. a 'ready for export' flag at
> the PWI
> > level - I can do that, but then I have to query each individual
> PWI again
> > to collect the Story- or Defect-specific custom field values. If I
> query
> > for PrimaryWorkitems and specify a Story- or Defect-specific field
> in the
> > 'sel=' parameter, I get an error.
> >
> > This makes sense, but I am wondering if there is a way
> around it so
> > that I can query 1 time for all Backlog items and get each one
> with their
> > type-specific custom fields.
> >
> > Thanks,
> >
> > -Will
> >
> > > -----Original Message-----
> > > From: version...@googlegroups.com
> <mailto:version...@googlegroups.com> <mailto:versionone-
> > d...@googlegroups.com> [mailto:versionone-
> > > d...@googlegroups.com] On Behalf Of ibuchanan
> > > Sent: Tuesday, April 10, 2012 9:13 AM
> > > To: version...@googlegroups.com <mailto:versionone-
> d...@googlegroups.com> <mailto:versionone-
> > d...@googlegroups.com>
> > > Subject: Re: How to retrieve Stories and Defects in one
> query
> > using Java
> > > SDK
> > >
> > > Anjum,
> > >
> > > The trick is that both Stories and Defects are
> PrimaryWorkitems.
> > You
> > > didn't mention which layer of the SDK you are using (API
> Client or
> > Object
> > > Model).
> > >
> > > Assuming API Client, you can follow the approach to get
> multiple
> > assets:
> > >
> >
> http://community.versionone.com/sdk/DetailedDocumentation/SDK%20.Net/apicl
> <http://community.versionone.com/sdk/DetailedDocumentation/SDK%20.Net/apic
> l>
> >
> <http://community.versionone.com/sdk/DetailedDocumentation/SDK%20.Net/apic
> <http://community.versionone.com/sdk/DetailedDocumentation/SDK%20.Net/apic
> >
> > l>
> > > ient/apiclient.html#query.assets
> > >
> > > Just change the asset type to PrimaryWorkitem:
> > > IAssetType storyType =
> metaModel.GetAssetType("PrimaryWorkitem");
> > >
> > > (Note: ideally, you also rename the variable to
> > primaryWorkitemType but
> > > the above makes it simple for copy/paste.)
> > >
> > > Yours truly,
> > > Ian Buchanan
> > > Product Manager for Platform and Integrations
> > >
> > >
> > > On Tuesday, April 10, 2012 8:46:13 AM UTC-4, Anjum
> Naseer wrote:
> > >
> > > Hi,
> > >
> > >
> > >
> > > I am trying to retrieve both Stories and Defects
> from a
> > particular
> > > sprint in one query and want them returned ordered by
> the Order
> > field.
> > >
> > >
> > >
> > > I have successfully managed to retrieve just
> Stories using
> > the Java
> > > API but cannot work out how to construct a query that
> will return
> > both
> > > Stories AND Defects in one go.
> > >
> > >
> > >
> > > Thanks.
> > >
> > >
> > >
> > > Anjum.
> > >
> > >
> > >
> > > PS: I am using the latest Enterprise release of
> V1
> > (12.0.1.2915) and
> > > the latest Java SDK (VersionOne.JavaSDK-12.0).
> > >
> > > --
> > > You received this message because you are subscribed to
> the Google
> > Groups
> > > "VersionOne-dev" group.
> > > To view this discussion on the web visit
> > > https://groups.google.com/d/msg/versionone-dev/-
> /gX2hTHigoEMJ <https://groups.google.com/d/msg/versionone-dev/-
> /gX2hTHigoEMJ>
> > <https://groups.google.com/d/msg/versionone-dev/-/gX2hTHigoEMJ
> <https://groups.google.com/d/msg/versionone-dev/-/gX2hTHigoEMJ> > .
> > > To post to this group, send email to versionone-
> > d...@googlegroups.com <mailto:version...@googlegroups.com
> <mailto:version...@googlegroups.com> > .
> > > To unsubscribe from this group, send email to
> versionone-
> > > dev+uns...@googlegroups.com
> <mailto:dev%2Bunsu...@googlegroups.com>
> > <mailto:dev%2Bunsu...@googlegroups.com
> <mailto:dev%252Buns...@googlegroups.com> > .
> > > For more options, visit this group at
> > > http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en>
> > <http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> > .
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "VersionOne-dev" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/versionone-dev/-/dlnufBp0ZYoJ
> <https://groups.google.com/d/msg/versionone-dev/-/dlnufBp0ZYoJ> .
> > To post to this group, send email to versionone-
> d...@googlegroups.com <mailto:version...@googlegroups.com> .
> > To unsubscribe from this group, send email to versionone-
> > dev+uns...@googlegroups.com
> <mailto:dev%2Bunsu...@googlegroups.com> .
> > For more options, visit this group at
> > http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> .
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "VersionOne-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/versionone-dev/-/SWd_M72hXJoJ.
> To post to this group, send email to version...@googlegroups.com.
> To unsubscribe from this group, send email to versionone-
> dev+uns...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/versionone-dev?hl=en.


ibuchanan

unread,
Apr 10, 2012, 12:18:37 PM4/10/12
to version...@googlegroups.com
Will,
 
It's not quite what you are doing. In my query, I had the Story and Defect selectors in front of the attribute name. To apply the same concept to your query (I bolded my change to try to make it more clear):
$url/PrimaryWorkitem?sel=StandardProperty,Story.Custom_Story1,Defect.Custom_Defect2&where=Custom_PWI_ExportFlag='yes'
 
Let me know if that doesn't work for you.
Ian,

        $url/PrimaryWorkitem?sel=StandardProperty,Custom_Story1,Custom_Defect2&where=Custom_PWI_ExportFlag='yes'

        $url/PrimaryWorkitem?sel=StandardProperty&where=Custom_PWI_ExportFlag='yes'

Then for each item:

>         > d...@googlegroups.com <mailto:versionone-dev@googlegroups.com
> <mailto:versionone-dev@googlegroups.com> > .


>         >         > To unsubscribe from this group, send email to
> versionone-

>         >         > dev+unsubscribe@googlegroups.com
> <mailto:dev%2Bunsubscribe@googlegroups.com>
>         > <mailto:dev%2Bunsubscribe@googlegroups.com
> <mailto:dev%252Bunsubscribe@googlegroups.com> > .


>         >         > For more options, visit this group at
>         >         > http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en>
>         > <http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> > .
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         > --
>         > You received this message because you are subscribed to the Google
> Groups
>         > "VersionOne-dev" group.
>         > To view this discussion on the web visit
>         > https://groups.google.com/d/msg/versionone-dev/-/dlnufBp0ZYoJ
> <https://groups.google.com/d/msg/versionone-dev/-/dlnufBp0ZYoJ> .
>         > To post to this group, send email to versionone-

> d...@googlegroups.com <mailto:versionone-dev@googlegroups.com> .


>         > To unsubscribe from this group, send email to versionone-

>         > dev+unsubscribe@googlegroups.com
> <mailto:dev%2Bunsubscribe@googlegroups.com> .


>         > For more options, visit this group at
>         > http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> .
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "VersionOne-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/versionone-dev/-/SWd_M72hXJoJ.

> To post to this group, send email to versionone-dev@googlegroups.com.


> To unsubscribe from this group, send email to versionone-

> dev+unsubscribe@googlegroups.com.

Saxon, Will

unread,
Apr 10, 2012, 1:58:37 PM4/10/12
to version...@googlegroups.com
This is exactly what I was looking for and seems to work fine. Thanks.

-Will

> -----Original Message-----
> From: version...@googlegroups.com [mailto:versionone-
> d...@googlegroups.com] On Behalf Of ibuchanan
> Sent: Tuesday, April 10, 2012 12:19 PM
> To: version...@googlegroups.com
> Subject: Re: Retrieving work items with custom attributes via REST was RE:
> How to retrieve Stories and Defects in one query using Java SDK
>
> Will,
>

> > Sent: Tuesday, April 10, 2012 11:33 AM

> > To: version...@googlegroups.com <mailto:versionone-
> d...@googlegroups.com>
> > Subject: Re: How to retrieve Stories and Defects in one query
> using Java
> > SDK
> >
> > Will,
> >

> <http://community.versionone.com/sdk/Documentation/DataAPI.aspx#section.at

> <http://community.versionone.com/sdk/DetailedDocumentation/SDK%20.Net/apic
> <http://community.versionone.com/sdk/DetailedDocumentation/SDK%20.Net/apic

> dev/- <https://groups.google.com/d/msg/versionone-dev/->

> > > d...@googlegroups.com <mailto:versionone-
> d...@googlegroups.com <mailto:version...@googlegroups.com>
> > <mailto:version...@googlegroups.com <mailto:versionone-
> d...@googlegroups.com> > > .


> > > > To unsubscribe from this group, send email to
> > versionone-

> > > <mailto:dev%2Bunsu...@googlegroups.com
> <mailto:dev%252Buns...@googlegroups.com>
> > <mailto:dev%252Buns...@googlegroups.com
> <mailto:dev%25252Bun...@googlegroups.com> > > .


> > > > For more options, visit this group at
> > > > http://groups.google.com/group/versionone-

> dev?hl=en <http://groups.google.com/group/versionone-dev?hl=en>


> > <http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> >
> > > <http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en>
> > <http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> > > .
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > You received this message because you are subscribed to
> the Google
> > Groups
> > > "VersionOne-dev" group.
> > > To view this discussion on the web visit
> > > https://groups.google.com/d/msg/versionone-dev/-
> /dlnufBp0ZYoJ <https://groups.google.com/d/msg/versionone-dev/-
> /dlnufBp0ZYoJ>
> > <https://groups.google.com/d/msg/versionone-dev/-/dlnufBp0ZYoJ
> <https://groups.google.com/d/msg/versionone-dev/-/dlnufBp0ZYoJ> > .
> > > To post to this group, send email to versionone-

> > d...@googlegroups.com <mailto:version...@googlegroups.com
> <mailto:version...@googlegroups.com> > .


> > > To unsubscribe from this group, send email to
> versionone-

> <mailto:dev%252Buns...@googlegroups.com> > .


> > > For more options, visit this group at
> > > http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en>
> > <http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> > .
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "VersionOne-dev" group.
> > To view this discussion on the web visit

> > https://groups.google.com/d/msg/versionone-dev/-/SWd_M72hXJoJ
> <https://groups.google.com/d/msg/versionone-dev/-/SWd_M72hXJoJ> .


> > To post to this group, send email to versionone-

> d...@googlegroups.com <mailto:version...@googlegroups.com> .


> > To unsubscribe from this group, send email to versionone-

> > dev+uns...@googlegroups.com
> <mailto:dev%2Bunsu...@googlegroups.com> .


> > For more options, visit this group at
> > http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> .
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "VersionOne-dev" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/versionone-dev/-/Kd99TFVE1pMJ.
> To post to this group, send email to version...@googlegroups.com.


> To unsubscribe from this group, send email to versionone-

> dev+uns...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages