API select query on state or description field does not work

Hey,

I’m trying to select the single-select field “State” and rich text field “Description” via API.
For both I’m not quiet sure, if I’m doing something wrong:

[
         {
           "command": "fibery.entity/query",
           "args": {
             "query": {
               "q/from": "testing API/Database 2",
               "q/select": [
                "fibery/id",
                "fibery/public-id",
                "testing API/name",
                 { "testing API/State": ["enum/name"] },
                 { "testing API/Description": [ "Collaboration~Documents/secret" ] }

               ],
               "q/limit": 100
             }
           }
         }
       ]

Response 1:


[
    {
        "success": false,
        "result": {
            "name": "entity.error/query.invalid",
            "message": "Invalid query.\nCause: 'testing API/State' field was not found in 'testing API/Database 2' database.",
            "data": {
                "top": {
                    "error/name": "entity.error/query.invalid",
                    "query": {
                        "q/from": "testing API/Database 2",
                        "q/select": [
                            "fibery/id",
                            "fibery/public-id",
                            "testing API/name",
                            {
                                "testing API/State": [
                                    "enum/name"
                                ]
                            }
                        ],
                        "q/limit": 100
                    }
                },
                "cause": {
                    "error/name": "entity.error/schema-field-not-found",
                    "field": "testing API/State",
                    "type": "testing API/Database 2"
                }
            },
            "via": [
                {
                    "type": "clojure.lang.ExceptionInfo",
                    "message": "Invalid query.",
                    "data": {
                        "error/name": "entity.error/query.invalid",
                        "query": {
                            "q/from": "testing API/Database 2",
                            "q/select": [
                                "fibery/id",
                                "fibery/public-id",
                                "testing API/name",
                                {
                                    "testing API/State": [
                                        "enum/name"
                                    ]
                                }
                            ],
                            "q/limit": 100
                        }
                    },
                    "at": [
                        "core.ex$ex_info",
                        "invokeStatic",
                        "ex.clj",
                        81
                    ]
                },
                {
                    "type": "clojure.lang.ExceptionInfo",
                    "message": "'testing API/State' field was not found in 'testing API/Database 2' database.",
                    "data": {
                        "error/name": "entity.error/schema-field-not-found",
                        "field": "testing API/State",
                        "type": "testing API/Database 2"
                    },
                    "at": [
                        "core.ex$ex_info",
                        "invokeStatic",
                        "ex.clj",
                        81
                    ]
                }
            ]
        }
    }
]

Response 2:


[
    {
        "success": false,
        "result": {
            "name": "entity.error/query.invalid",
            "message": "Invalid query.\nCause: 'testing API/Description' field was not found in 'testing API/Database 2' database.",
            "data": {
                "top": {
                    "error/name": "entity.error/query.invalid",
                    "query": {
                        "q/from": "testing API/Database 2",
                        "q/select": [
                            "fibery/id",
                            "fibery/public-id",
                            "testing API/name",
                            {
                                "testing API/Description": [
                                    "Collaboration~Documents/secret"
                                ]
                            }
                        ],
                        "q/limit": 100
                    }
                },
                "cause": {
                    "error/name": "entity.error/schema-field-not-found",
                    "field": "testing API/Description",
                    "type": "testing API/Database 2"
                }
            },
            "via": [
                {
                    "type": "clojure.lang.ExceptionInfo",
                    "message": "Invalid query.",
                    "data": {
                        "error/name": "entity.error/query.invalid",
                        "query": {
                            "q/from": "testing API/Database 2",
                            "q/select": [
                                "fibery/id",
                                "fibery/public-id",
                                "testing API/name",
                                {
                                    "testing API/Description": [
                                        "Collaboration~Documents/secret"
                                    ]
                                }
                            ],
                            "q/limit": 100
                        }
                    },
                    "at": [
                        "core.ex$ex_info",
                        "invokeStatic",
                        "ex.clj",
                        81
                    ]
                },
                {
                    "type": "clojure.lang.ExceptionInfo",
                    "message": "'testing API/Description' field was not found in 'testing API/Database 2' database.",
                    "data": {
                        "error/name": "entity.error/schema-field-not-found",
                        "field": "testing API/Description",
                        "type": "testing API/Database 2"
                    },
                    "at": [
                        "core.ex$ex_info",
                        "invokeStatic",
                        "ex.clj",
                        81
                    ]
                }
            ]
        }
    }
]

You need to use "workflow/state" instead of "testing API/State"

(assuming that the State field was made by adding the workflow extension)

FYI, here’s a useful script to get all the fields of a given entity. It might help you figure out the correct names to use.

1 Like

Thank you that helped a lot!