Knowledge Base Article

> Knowledge Base > Spira Platform

Created By  inflectra.simon Tuesday, February 20, 2018

When using Spira's REST API, there are a number of calls that let you create powerful filters to query for only the specific information you want. These use a POST request with the filter in the body as either JSON or XML. Here's how to correctly formulate JSON to get only artifacts that fall between two dates.

[
  {
    "DateRangeValue": {
      "ConsiderTimes": false,
      "EndDate": "/Date(1070254800000-0500)/",	
      "StartDate": "/Date(1070254800000-0500)/"
    },
    "PropertyName":"LastUpdateDate"
  }
]

As you can see, we create a filter as an array of objects. each object is a single filter on a specific property (one key/value pair for the property name, one key/value pair for the property type and actual value to filter on). 

Here, we are creating a filter on the property "LastUpdateDate". Date fields need to be sent in a specific format. You can work this out by viewing any date field returned by the API. It is in the format "/Date({unixtime}{timezoneoffset})/".

For a date range we specify the property type as "DateRangeValue". This is an object which can take up to 3 key/value pairs:

  1. "ConsiderTimes" - boolean, requireed: Do we want to consider times when filtering
  2. "EndDate" - datetime (in the format specified above): the end date of the requested range
  3. "StartDate" - datetime (in the format specified above): the start date of the requested range
Article Info
  • Last Updated: 2/20/2018
  • Article ID: KB327
  • Views: 984