Rally Software

Expand all | Collapse all

How do I use date functions when querying REST API?

Jump to Best Answer
  • 1.  How do I use date functions when querying REST API?

    Posted 12-19-2016 08:33 AM

    When attempting to query a date field in the v2.0 of the REST API, how do I use date functions, such as Date.IsInThisYear()?  I seem to have no issue when using something like https://rally1.rallydev.com/slm/webservice/v2.0/defect?query=(OpenedDate%20%3E%3D%20%222016-01-01T00%3A00%3A00.000Z%22)&start=1&pagesize=20 but need to narrow the list based on date functions (like in this year, in this quarter, last 30 days, etc.).



  • 2.  Re: How do I use date functions when querying REST API?
    Best Answer

    Posted 12-21-2016 12:53 PM

    Hi Leslie,

    Our WSAPI does not include methods or functions to perform date calculations like you reference above. That being said, you could achieve this by first calculating the date range in question using your custom written application's programming language, then using the Query Expression Operators available tor the dateTime attribute in question.

     

    For example:

    To get a list of defects where the OpenedDate attribute is anytime this year, the following request would work:

    https://rally1.rallydev.com/slm/webservice/v2.0/defect?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/5555555555555&query=(( OpenedDate > "2016-01-01" ) and ( OpenedDate < "2016-12-31" ))&fetch=true&start=1&pagesize=20

    I took out the URL encoding to make it easier to read and the workspace id is invalid.

     

    To get the dates for the query above use your programming languages's methods. Some pseudo code below:

     

    String startDate = getFirstDateInYear('2016');

    String endDate = getLastDateInYear('2016');

    ...

    ...

    ...

    //Now run the commands to send the following request to rally:

    https://rally1.rallydev.com/slm/webservice/v2.0/defect?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/5555555555555&query=(( OpenedDate > startDate ) and ( OpenedDate < endDate ))&fetch=true&start=1&pagesize=20

     

    Does that help? I see you logged a support ticket, so I will send this information to you through that ticket also.

     



  • 3.  Re: How do I use date functions when querying REST API?

    Posted 12-21-2016 01:07 PM

    It does!  Thank you!!!!

     

    My only hiccup at the moment is that I'm trying to do it within PowerBI for dashboard purposes.  I'll see what I can do though - just looking to grab only a subset of the records using the query parameter.



  • 4.  Re: How do I use date functions when querying REST API?

    Posted 12-21-2016 01:17 PM

    Glad it helped! I know almost nothing about PowerBI or I would offer additional help.