-2

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 Answers2

0

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

Luis Vivas
  • 95
  • 3
  • 9
0

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' 
})