skip to Main Content

How do you create new item on monday using python? Below is the code that is being used — on a board there are multiple columns that need to be populated. How to target a specific column and provide it with a value?

def CREATE_data(api_key:str) -> None:
    ''' fn creates new row item on Monday.com '''
    api_url     = "https://api.monday.com/v2" 
    headers     = {'Authorization': api_key}
    query       = 'mutation ($columnVals: JSON!) { create_item (board_id:3539729472, item_name:"TEST", column_values: $columnVals) { id } }'
    vars        = {
        'columnVals': json.dumps({ 
                'date' : '1993-08-27' 
        })
    }
    data        = {'query' : query, 'variables': vars}
    r = requests.post(url=api_url, json=data, headers=headers) # make request
    print(r.json()) 

Tired the code above and am trying to populate specific columns with values

2

Answers


  1. Chosen as BEST ANSWER

    The solution - to target specific columns is to create a JSON and provide it with the column ID. EX:

    'columnVals': json.dumps({
       # col_ID : col_val 
       'text11' : 'your text here' 
       'status14': 'Overnight' 
    })
    

  2. There is not much information of what exactly you are trying but according to the tutorial. You have to specify the columns with the json.

    query3 = 'mutation{ create_item (board_id:YOUR_BOARD_ID, item_name:"WHAT IS UP MY FRIENDS!") { id } }'
    data = {'query' : query3}
    

    Look at creating a new item. https://support.monday.com/hc/en-us/articles/360013483119-API-Quickstart-Tutorial-Python

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search