Updating a linked_board column's value with python request

I have used the very helpful quickstart Tutorials (API Quickstart Tutorial - Python – Support (monday.com))as templates and attempted to write Python code to query boards. The querying part works fine. I have successfully posted requests and received sensible data from boards in my Monday.com account. I am therefore sure that the API Key, Url etc for the headers are correct and working fine.

Changing the “value” of a “linked board” column, proofs to be elusive. No matter how I tried adapting the examples from the turtorials, I cannot update the linked column’s “value”.

On Sep 24, 2020, “Captain” posted a topic with almost identical content for assistance - Change_column_value NOT WORKING in python - FAQs - monday Community. There were zero replies to the topic since then. I hope this is not because the problem has no solution.

Below is the code snippet:

mutation = “mutation {change_column_value (board_id: 123456789, item_id:1205882003,column_id:"linked_board_col",value:"{"linkedPulseIds":[{"linkedPulseId":1205923661}],"changed_at":"2021-04-12T20:09:37.996Z"}"){id}}”
data = {‘query’ : mutation}
r = requests.post(url=apiUrl, json=data, headers=headers) # make request
print(r.json())

This results in the following error:

{‘errors’: [{‘message’: ‘Parse error on “:[{” (STRING) at [1, 152]’, ‘locations’: [{‘line’: 1, ‘column’: 152}]}], ‘account_id’: 8564194}

Process finished with exit code 0

Please assist.

Hey @louisdl
Actually there’s an error in your query.
If you put it into the API Playground you’ll find it gives you an error.
First of all, I don’t know if it’s something related to this forum style, but you need to use straight double quotes " instead of the diagonal ones .
Then you need to escape all double quotes inside strings

value:"{"linkedPulseIds...

must be replaced with

value:"{\"linkedPulseIds...

It’s all clearly explained in documentation.

I copied the text into the Monday.com Topic area from a text editor which I used to prepare the content of my post. I did not realize that some characters got lost in the copying and pasting - my code actually had all the escapes for the double quotes, and, it had the straight quotes.

I will post the same again and see if I can improve my post’s accuracy.

mutation - ‘mutation {change_column_value (board_id: 123456789,
item_id:1205882003, column_id:'linked_board_col', value:'{'linkedPulseIds':
[{'linkedPulseId':1205923661}],'changed_at':'2021-04-12T20:09:37.996Z'}'){id}’
data = {‘query’ : mutation}
r = requests.post(url=apiUrl, json=data, headers=headers) # make request
print(r.json())

It seems that the escapes gets lost in translation. Please assume that all quotes inside the the brackets has an escape character (backslash \ ) . I do not know why it does not show when I submit the post

Hi @louisdl!

I believe we were communicating via email as well, but it seems you were able to resolve your issue!

For future readers, I had recommended trying out this structure instead, and I think it may have helped:

mutation { change_column_value( board_id:1234567, item_id:1234567, column_id:"connect_boards20", value:"{\"item_ids\":[1234567]}"){ id } }

Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.