0

I am trying to use python to automation common Monday tasks. I am able to create an item in the board but the column (type=tag) is not updating.

I used this tutorial: https://support.monday.com/hc/en-us/articles/360013483119-API-Quickstart-Tutorial-Python#

Here is my graphql code that I am executing:

query = 'mutation ($device: String!, $columnVals: JSON!) { create_item (board_id:<myboardid>, item_name:$device, column_values:$columnVals) { id } }' 
vars = {'device': device,
        'columnVals': json.dumps({
            'cloud_name6': {'text': cloudname}  # this is where i want to add a tag. cloud_name6 is id of the column.
        })
        } 
data = {'query' : query, 'variables' : vars}

r = requests.post(url=apiUrl, json=data, headers=headers) print(r.json())

I have tried changing id to title as key in the Json string but no luck. I fetched the existing item and tried to add exact json string but still no luck. I also tried below json data without any luck

'columnVals': json.dumps({
            'cloud_name6': cloudname
        })

Any idea what's wrong with the query?

Krishnom
  • 1,348
  • 12
  • 39

1 Answers1

0

When creating or mutating tag columns via item queries, you need to send an array of ids of the tags ("tag_ids") that are relating to this item. You don't set or alter tag names via an item query.

Corrected Code

'columnVals': json.dumps({
        'cloud_name6': {'tag_ids': [295026,295064]}
    })

https://developer.monday.com/api-reference/docs/tags

Jennifer Goncalves
  • 1,442
  • 1
  • 12
  • 29