# API select query on state or description field does not work

**URL:** <https://community.fibery.io/t/api-select-query-on-state-or-description-field-does-not-work/3069>\
**Category:** Get Help\
**Created:** [July 13, 2022, 2:59pm UTC](https://community.fibery.io/t/api-select-query-on-state-or-description-field-does-not-work/3069 "2022-07-13T14:59:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lug-gl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/lug-gl/32/5293_2.png) [@Lug-gl](https://community.fibery.io/u/Lug-gl)\
**Post date:** [July 13, 2022, 2:59pm UTC](https://community.fibery.io/t/api-select-query-on-state-or-description-field-does-not-work/3069/1 "2022-07-13T14:59:29Z")

</div>

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:

```auto
[
         {
           "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:

```auto

[
    {
        "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:

```auto

[
    {
        "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
                    ]
                }
            ]
        }
    }
]

```

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [July 13, 2022, 3:11pm UTC](https://community.fibery.io/t/api-select-query-on-state-or-description-field-does-not-work/3069/2 "2022-07-13T15:11:37Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [July 13, 2022, 3:18pm UTC](https://community.fibery.io/t/api-select-query-on-state-or-description-field-does-not-work/3069/3 "2022-07-13T15:18:37Z")

</div>

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.

> [@Getting all field values for an entity](https://community.fibery.io/t/getting-all-field-values-for-an-entity/2801):
>
> Here’s a little scripting snippet for how to retrieve all the information about an entity, without knowing or hard-coding the space name, database name or field names: const fibery = context.getService('fibery'); // get entire schema const schema = await fibery.getSchema(); // get specific database (type) name const typeName = args.currentEntities[0].type; // filter the schema for the specific type and get all field names const fields = schema['typeObjects'].filter((obj) =\> obj.name == typeName…

---

<div class="post-metadata">

**Author:** ![Lug-gl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/lug-gl/32/5293_2.png) [@Lug-gl](https://community.fibery.io/u/Lug-gl)\
**Post date:** [July 14, 2022, 7:19am UTC](https://community.fibery.io/t/api-select-query-on-state-or-description-field-does-not-work/3069/4 "2022-07-14T07:19:06Z")

</div>

Thank you that helped a lot!
