Python Monday.com 创建新板

问题描述 投票:0回答:1

我已阅读 monday.com API 文档,但未能成功在给定工作区中创建新板。代码运行并给出

status_code == 200
,但是该工作区中没有创建新板。这是因为没有添加数据吗?

import requests
import json

start = timeit.default_timer()

apiKey = 'xxx'
apiUrl = "https://api.monday.com/v2"
headers = {"Authorization" : apiKey,
           "Content-Type" : 'application/json',
           "API-Version" : '2023-10'}

board_kind = 'private'
board_name = 'Baulder Gate 3'
description = 'My Campaign'
workspace_id = 'xxx'


payload = f"""
mutation {{
    create_board (
        board_kind: {board_kind},
        board_name: {board_name},
        description: {description},
        workspace_id: {workspace_id}) {{
        
        id
        }}
}}
"""

data = {'query' : payload}
r_boards = requests.post(url=apiUrl, headers=headers, data=json.dumps(data)) # make request

if r_boards.status_code == 200:
    print("board was created")
python post monday.com
1个回答
0
投票

我能够找到我的错误。打印出来后

r_boards.json()
我收到了类似的错误消息:

{'errors': [{'message': 'Parse error on "3" (INT) at [3, 69]', 'locations': [{'line': 3, 'column': 69}]}], 'account_id': xxx}

我的一些数据类型不正确。这是我改变的:

def create_board():
    payload = f"""
    mutation {{
        create_board (
            board_kind: {board_kind},
            board_name: {json.dumps(board_name)},
            description: {json.dumps(description)},
            workspace_id: {json.dumps(workspace_id)}) {{
            
            id
            }}
        
    }}
    """
© www.soinside.com 2019 - 2024. All rights reserved.