Skip to main content

Change multiple column values syntax

  • September 15, 2023
  • 8 replies
  • 558 views

  • Participating Frequently

query = ’ mutation { change_multiple_column_values(item_id: 1234567890, board_id: 1234567890, column_values: {“text”: “New text” }) { id } } ’

keeps returning

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

I’m not sure where I’m going wrong although, any help would be appreciated

8 replies

basdebruin
  • Community Expert
  • September 15, 2023

hi @dog

You need to JSON stringify the column_values value. You can also do that with escaped double quotes, like this:

mutation { change_multiple_column_values(item_id: 1234567890, board_id: 1234567890, column_values: "{\\"text\\": \\"New text\\"}" ) { id } }

PS: if you post queries here, always use preformatted text as the forum will do all kind of nasty things with “double” quotes


  • Author
  • Participating Frequently
  • September 15, 2023

Hello,
I tested that solution, but it only worked for me once I tripled up on the backslashes. I don’t really understand why, I saw it in another forum post somewhere. Is there a good explanation as to why?


basdebruin
  • Community Expert
  • September 15, 2023

It depends in which environment you are working. The above works in the API Playground. Other environments might need more escaping. The eassiest way to build a JSON stringified string in JS is to use JSON.stringify()


  • Author
  • Participating Frequently
  • September 15, 2023

Thank you for your time so far, I am lastly trying to place variables in this query however I am getting errors once again.

query = ' mutation ($totalServerCount: String!) { change_multiple_column_values(item_id: xxxxxxxx, board_id: xxxxxxxx, column_values:"{\\\\\\"text\\\\\\": $totalServerCount, \\\\\\"text5\\\\\\": \\\\\\"4\\\\\\"}") { id } } '
vars = {
    'totalServerCount' : str(totalServerCount),
        }
data = {'query' : query, 'variables' : vars}

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

I assume it would be in this format as this is what I’ve done for other queries, however I am getting the error {‘error_message’: ‘809: unexpected token at '{“text”: $totalServerCount, “text5”: “4”}'’, ‘status_code’: 500}


basdebruin
  • Community Expert
  • September 15, 2023

Is the content of $totalServerCount still escaping the double quotes?

It is much easier to use a function to stringify a JSON and almost every language has some kind of function to do that. What language are you using?


  • Author
  • Participating Frequently
  • September 15, 2023

I am using Python, so would you recommend in vars defining the the column values and using json.dumps to convert it to JSON and then use something like column_values: $columnVars?


basdebruin
  • Community Expert
  • September 15, 2023

Absolutely the best thing to do


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • September 18, 2023

Thank you @basdebruin for your help as usual 👑 !!!

@dog let us know if you need anything else!

Cheers,
Matias