Skip to content

ColumnTypes is not JSON serializable #109

Description

@basteks

While trying to use a member of the ColumnTypes class in a dict object, we get a TypeError: Object of type ColumnTypes is not JSON serializable.

This is quite counterintuitive as most of the columns functions require a ColumnTypes member instead of a simple string such as 'text' or 'number', whereas you can't provide such a member in an API request such as:

import requests
from seatable_api import Base, context
from seatable_api.constants import ColumnTypes

base = Base(context.api_token, context.server_url)
base.auth()

url = f"https://cloud.seatable.io/api-gateway/api/v2/dtables/{base.dtable_uuid}/columns"

payload = {
    "op_type": "modify_column_type",
    "column_data": {
        "table": "Table1",
        "other_table": "Table2"
    },
    "table_name": "Table1",
    "column": "aa",
    "new_column_type": ColumnTypes.IMAGE # for now, you have to write 'image'
}

headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": f"Bearer {base.jwt_token}"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions