Problem with creating items in Monday.com using Python requests Text

Hi

I am implementing a Python script to create items in a Monday.com table using the V2 API. I have followed the API documentation but I am still having problems with creating elements.

Here is my code:

import requests
import json

api_key = 'TU_API_KEY'

url = 'https://api.monday.com/v2/'

query = '''
mutation {
  create_item(
    board_id: "BOARD_ID",
    item_name: "NOMBRE_TAREA",
    column_values: "{\"column_id\": \"COLUMN_VALUE\"}"
  ) {
    id
  }
}
'''

headers = {
  'Content-Type': 'application/json',
  'Authorization': api_key
}

response = requests.post(url=url, json={'query': query}, headers=headers)

print(response.json())

However, when I run this code, I get the following error:

{'errors': [{'message': 'Parse error on ": " (STRING) at [6, 40]', 'locations': [{'line': 6, 'column': 40}]}], 'account_id': 16382470}

I have verified that the table ID, API key and column_values are correct, but still I can’t fix the problem.

I would be very grateful if someone could help me to solve this problem. Thank you very much in advance.

Hello @Jose80932 and welcome to the community!

I hope you like it here :muscle:

Would you be able to please send over the mutation exactly the way you are trying to use it with the actual values for the board ID, item name, column ID and column value, instead of showing the names of the variables?

Looking forward to hearing from you!

Cheers,
Matias