Hello,
I am using Python to query monday API.
I have been spending many hours trying to use “change_column_value” on a link column, in vain.
I saw I wasn’t the only one to have this issue but I still couldn’t solve it.
This is my code:
def update_field(item_id: int, column_id: str, value):
value_str = json.dumps(value).replace('"', '\\"')
print(value_str)
query = f'''
mutation {{
change_simple_column_value(
board_id: {BOARD_ID},
item_id: {item_id},
column_id: "{column_id}",
value: "{value_str}"
) {{
id
}}
}}
'''
response = requests.post(url=MONDAY_URL, json={'query': query}, headers=monday_headers)
return response.json()
some_url = 'https://www.google.com'
some_text = 'Google'
print(update_field(item_id=item_id, column_id='link', value={'url': some_url, 'text': some_text}).json())
This code returns:
{\"url\": \"https://www.google.com", \"text\": \"Google\"}
{'data': {'change_simple_column_value': {'id': '0000000000'}}, 'account_id': 00000000}
(I replaced the numbers by 0 for safety matters)
When I print json.dumps(value_str)
I get {"url": "https://www.google.com", "text": "Google"}
.
Returning back on my Monday board, I can see that the changes have been done, but not accurately. Here is what I get when I get the item:
{'id': 'link', 'title': 'Link column', 'value': '{"url":"https://%7B%22url%22:","text":"\\"https://www.google.com\\", \\"text\\": \\"Google\\"}","changed_at":"2023-05-12T10:14:02.242Z"}'}
I would be grateful if you could help me through this issue.
twan