AntonL
(Anton)
April 6, 2022, 3:11pm
1
hi all
i’m trying to create an new item with column value
MONDAY_APIKEY = os.getenv("MONDAY_APIKEY")
MONDAY_BASE_URI = "https://api.monday.com/v2"
MONDAY_HEADERS = {"Authorization": MONDAY_APIKEY}
vars = '''{
boardId: 00000000000,
itemName: "new item from python",
columnValues: {"numbers": {"value": "22222"}}
}'''
query = f'''mutation ($boardId: Int!, $itemName: String!, $columnValues: JSON!)
{{create_item(board_id: $boardId, item_name: $itemName, column_values: $columnValues) {{id}}}}'''
query_to_run = {'query': query, 'variables': vars}
r = requests.post(url=MONDAY_BASE_URI, json=query_to_run, headers=MONDAY_HEADERS)
response = r.json()
“numbers” - it’s a column ID
getting: <Response [500]>
no any other error description
advice please
basdebruin
(Bas de Bruin)
April 6, 2022, 10:12pm
2
Hi @AntonL
Welcome to the community! I am not a Python expert, but I think the issue is the value in columnValues. That need to be a stingified JSON, and now it is an object. Try this one where the quotes are escaped:
columnValues: "{\"numbers\": {\"value\": \"22222\"}}"
Hello @AntonL and welcome to the community!
I hope you like it here
You can use a mutation like this one here:
mutation {
create_item(board_id: 12345678, item_name: "new item", column_values: "{\"numbers\": 200}") {
id
}
}
and just pass the number as a number.
Cheers,
Matias
AntonL
(Anton)
April 7, 2022, 7:53am
4
thank you for reply
no didnt help
{‘query’: ‘mutation {create_item(board_id: 12345678, item_name: “new item”, column_values: “{“numbers”: 200}”) {id}}’}
response:
{‘errors’: [{‘message’: ‘Parse error on “: 200}” (STRING) at [1, 91]’, ‘locations’: [{‘line’: 1, ‘column’: 91}]}]
You still need to escape the double quotes inside the string. You are now trying to send a single { as the value as the second quote closes the string openend by the first quote.
AntonL
(Anton)
April 7, 2022, 9:00am
6
basdebruin:
stingified JSON
i’ve received success with next code
python code:
query = '''mutation {
create_item(board_id: 123456789, item_name: "new item", column_values: "{\\\"numbers\\\": -123}") {
id
}
}'''
in console(print) this text looks
{‘query’: ‘mutation {\n create_item(board_id: 1456732577, item_name: “new item”, column_values: “{\“numbers\”: -123}”) {\n id\n }\n }’}
thanks for advice!
system
(system)
Closed
April 14, 2022, 9:00am
7
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.