You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Merge pull request #110 from seatable/columntypes-json-serialization