Imzachjohnson / clickupython

A client for working with the ClickUp API V2
https://clickupython.readthedocs.io/
54 stars 33 forks source link

Priority is not integer #66

Open omiderfanmanesh opened 8 months ago

omiderfanmanesh commented 8 months ago

When I set Priority in Clickup dashboard (e.g. High), I get this error

Traceback (most recent call last):
  File "C:\PROJECT\Clickup\main.py", line 29, in main
    click_up_client.fetch_data()
  File "C:\PROJECT\Clickup\request_manager\clickup\client.py", line 40, in fetch_data
    tasks = c.get_tasks(self.list_id, include_closed=True)
  File "C:\Users\x\.conda\envs\general\lib\site-packages\clickupython\client.py", line 631, in get_tasks
    return models.Tasks.build_tasks(fetched_tasks)
  File "C:\Users\x\.conda\envs\general\lib\site-packages\clickupython\models.py", line 703, in build_tasks
    return Tasks(**self)
  File "pydantic\main.py", line 406, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Tasks
tasks -> 2 -> priority
  value is not a valid integer (type=type_error.integer)

This is a part of the result as json from postman and clickup api


          "watchers": [],
            "checklists": [],
            "tags": [],
            "parent": null,
            "priority": {
                "color": "#f8ae00",
                "id": "2",
                "orderindex": "2",
                "priority": "high"
            },

as you see, the Priority is a JSON object, not an int.

So what is the solution?

Tianqi-Dotes commented 7 months ago

Got the same issue here. image

nikpelgr commented 7 months ago

Had the same issue. Needed to work on the client.py and models.py and did the following changes manually on my venv:

  1. in client.py, replaced all 'priority: int = None' to 'priority: str = None' and 'priority: int' to 'priority: str'
  2. in models.py, replaced the 'priority: Any = None' to 'priority: str = None', 'priority: Any' to 'priority: str' and in the Task Class 'priority: Optional[Any] = None' to 'priority: Optional[Priority] = None'

In my program I had to update the code to use the objects correctly and now I have a syncer that gets tasks from Jira down to Clickup without any issue.