Accessing workflow via API

I’m writing a Python script to sync tasks between fibery and todoist. It was working great until I tried to access a Workflow element on my fibery task entities. I’m using the following query (the Strategy and Planning is a version of the GIST app that I have tweaked to fit my needs, and the workflow field is called “State”):

   [{"command": "fibery.entity/query", 
     "args": {"query": {"q/from": "Strategy and Planning/Task",
                                "q/select": ["Strategy and Planning/name", 
                                                  "Strategy and Planning/State"], 
                                "q/limit": "q/no-limit"}
                 }
   }]'

I get the error “Invalid query.\nCause: Field ‘Strategy and Planning/State’ was not found in ‘Strategy and Planning/Task’ type.” If I take out the “Strategy and Planning/State” part it works fine.

Is it not possible to access workflows through the API or am I doing something wrong?

Hi!
This query shape should work:

[{"command": "fibery.entity/query",
  "args": {"query": {"q/from": "Strategy and Planning/Task",
                     "q/select": ["Strategy and Planning/name",
                                  {"workflow/state": ["fibery/id", "enum/name"]}],
                    "q/limit": "q/no-limit"}
          }
  }]
1 Like

It certainly possible. You have couple errors in your query. First one is that the Workflow is an extension, so it adds own field to a type. This field name is workflow/state. The second is that this field is not a basic but a reference to a compound entity with own fields like fibery/id and enum/name. It’s a pity that in the Fibery you cannot list all of this visually, but you can take a closer look into output of {command: "fibery.schema/query", args: {}}.

So, in your case, query should look like in Andrew’s answer

1 Like

Wonderful! Thank you both so much. I’m still learning my way around the API and this helps a lot.