2 Replies Latest reply on Oct 2, 2018 9:10 AM by jmedd

    vRO REST API: querying workflows by categoryID

    jmedd Enthusiast
    vExpert

      In PowervRO we have a function Get-vROWorkflow which uses the vRO REST API to query workflows:

       

      PowervRO/Get-vROWorkflow.ps1 at master · jakkulabs/PowervRO · GitHub

       

      One of the options is to query by categoryName using the following URL:

       

      "/vco/api/workflows/?conditions=categoryName=$($Category)"
      

       

      We have a request to enhance this function to instead be able to query by categoryID. I tried the following, but it did not work and also could not find any documentation on how to discover what other 'conditions' are available:

       

      "/vco/api/workflows/?conditions=categoryId=$($CategoryId)"
      

       

      Is it possible to query the workflows API using a categoryId as a condition? If so, how should it be formed?

        • 1. Re: vRO REST API: querying workflows by categoryID
          iiliev Champion
          VMware EmployeesCommunity Warriors

          Hi Jonathan,

           

          Workflow's properties that could be used in this conditional filtering are id, name, description, categoryName and version. So currently it is not possible to use categoryId in a condition, unless we add some code to do so on vRO server side (feel free to open a PR about it).

           

          There is a workaround, though. You can get the same result in two steps:

           

          1) Make a GET request to fetch the category with the given categoryId. It could be something like:

          GET /vco/api/catalog/System/WorkflowCategory?conditions=id=ff80808165ed93fd0165ed955493000f
          

           

          The returned response content should contain a href to the category object. Look for a link element that looks similar to:

          <link href="https://10.20.30.50:8281/vco/api/catalog/System/WorkflowCategory/ff80808165ed93fd0165ed955493000f/" rel="down">
          

           

          2) Using the value of this href element, append workflows at its end (that's the name of the relation from the category to its child workflows). The URL should look like:

          https://10.20.30.50:8281/vco/api/catalog/System/WorkflowCategory/ff80808165ed93fd0165ed955493000f/workflows
          

           

          Now, if you make GET request with this URL, you'll get the list of workflows that are within this category.

           

          Hope the above makes sense.

          • 2. Re: vRO REST API: querying workflows by categoryID
            jmedd Enthusiast
            vExpert

            Excellent, that works great - thanks a lot!