Change multiple column values syntax

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

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

2 Likes

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?

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()

1 Like

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}

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?

1 Like

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?

Absolutely the best thing to do

3 Likes

Thank you @basdebruin for your help as usual :crown: !!!

@dog let us know if you need anything else!

Cheers,
Matias

1 Like