Search code examples
rallywsapi

Rally WSAPI query for latest revision


I need to use the Rally WSAPI to get the user who did the latest modification on an artifact. Ideally, I would like to either be able to fetch the user directly from the artifact itself. However, It only seems to have last modification date, not last modifier.

I looked at using revisions. It is not clear how I can query for revisions belonging to a specific artifact. I know the _ref value of the RevisionHistory object, but trying to use that in query for revisions did not work. I saw another answer suggesting fetching the whole list of revisions and just taking the first one, assuming they are ordered by descending chronological order by default. That will work, but it's somewhat inefficient.

I also don't know how to sort in descending order. I could use revision number to sort, and then take the latest revision. Alternatively, I could filter by creation date.

Thanks, Yaron


Solution

  • First fetch the RevisionHistory for the artifact in question:

    https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/<id>?fetch=revisionhistory
    

    Then fetch the most recent Revision from the Revisions collection for the returned RevisionHistory, fetching User and sorting by CreationDate desc:

    https://rally1.rallydev.com/slm/webservice/v2.0/revisionhistory/<id>/revisions?order=CreationDate desc&fetch=User,Description