Search code examples
pythonapipostmanplotly-dashversionone

Adding OR condition in VersionOne Query API


I am querying the V1 (/query.v1 API) via Python/Dash to get all stories tagged with certain tags.

The Where criteria for API Body is

"where": {
    "TaggedWith":"Search-Module" ,
    "Team.ID": "Team:009"
},

but I wanted to add OR criteria (something like assets tagged with "Search-Module OR Result-Module")

"where": {
    "TaggedWith":"Search-Module;Result-Module" ,
    "Team.ID": "Team:009"
},

The documentation in V1 is very basic and I am not able to find the correct way for additional criteria.

https://community.versionone.com/VersionOne_Connect/Developer_Library/Sample_Code/Tour_of_query.v1

Any pointers are appreciated.


Solution

  • You can set alternative values to a variable in the with property and use that variable within the where or filter property values:

    {
      "from": "Story",
      "select": [
        "Name"
      ],
      "where": {
        "Team.ID": "Team:009",
        "TaggedWith": "$tags"
      },
      "with": {
        "$tags": [
            "Search-Module",
            "Result-Module"
        ]
      }
    }
    

    As an option, you can use , (comma) as a separator:

    "with": {
        "$tags": "Search-Module,Result-Module"
    }
    

    The last example of the multi-value variable (but for the rest-1.v1 endpoint) has been found in the VersionOne Grammar project.