Change multiple column values in Python

I have been testing the requests I have been sending both through Monday.com API tester and my own script and I run into the same issues, a 500 internal server error. I have been able to eliminate it as parse error. If it is a column validation error I am unsure where it is if it is there.

mutation {change_multiple_column_values (board_id: *******, item_id: ******, column_values: {“ColumnID_1”: “Example Text”, “12345”, “Text_name1”: “No”, “text4”: " ", “status1”: {“label”: “Operating”}}) { id } }

I am sending it as written below in a python script. Elsewhere in this script I have queried items so I know the API is working

            Mut2 = ' mutation  ( $id: Int!,  $columnVals: JSON!)  {change_multiple_column_values (board_id: ********, item_id: $id, column_values: $columnVals) { id } }'
            vars = {'id' : ID, 'columnVals' : json.dumps(JSONdict)}
            dataUP = {'query' : Mut2, 'variables' : vars}
            Req = requests.post(url=apiUrl, json=dataUP, headers=headers)

As a side note for the last part of the mutation “{ id } }” is there documentation for what is required in this final part?

Hi there @Eric_MSI! :wave:

To be transparent with you, I am not a Python Developer myself, so I’m afraid I’m not able to shed too much light on that. That said, looking at the query you have provided, it seems like the values you are trying to send to the platform are not formatted as JSON values properly, which is why you are getting the 500 server error. I’m sorry that error is a bit vague for now :slight_smile:

Here is a sample mutation that changes a person column values on a board:
mutation {

  change_column_value (board_id: xxxxxxx, item_id: xxxxxxxxx, column_id: "person", value: "{\"personsAndTeams\":[{\"id\":4679523,\"kind\":\"person\"}]}") {
    id
  }
}

Notice how the JSON is escaped/formatted in a different way? I believe that by making the same adjustments to your code, the query should work properly. You can find more info on this here:

API Quickstart Tutorial - Python

-Alex

Thanks for the feedback. I actually have a line in my python

json.dumps(JSONdict)

that formats the input JSON string correctly.

Would you have an example for changing multiple column values. I believe that is where I am having the issue with the formatting.

The example on https://monday.com/developers/v2 only uses a single column ID for their multiple column change example (Also using “status” as a column ID suggests you need to have the column type listed vs the column ID)

mutation {
change_multiple_column_values (board_id: 20178755, item_id: 200819371, column_values: "{\"status\": {\"index\": 1}}") { id }}

Would changing multiple columns with a Text, Number and Status column types look like:

 mutation {change_multiple_column_values (board_id: *******, item_id: ******, column_values: {\“ColumnID_1\”: \“Example Text\”, \“12345\”,  \“status1\”: {\“label\”: \“Operating\”}}) { id } }

In the example you gave is “id” and “kind” two types of columns? (a number and text)?|
Just trying to get some context for your example.

\"id\":4679523,\"kind\":\"person\"

@AlexSavchuk

Hey Alex any updates for the questions I have?

realized I missed a " " in the example I gave

mutation {change_multiple_column_values (board_id: *******, item_id: ******, column_values: "{\“ColumnID_1\”: \“Example Text\”, \“12345\”,  \“status1\”: {\“label\”: \“Operating\”}}") { id } }

Any Updates also having same issue @AlexSavchuk

@Eric_MSI @Shiv

Sorry for the delay in getting back to you on this! I will have to consult with the team further on this before I can provide further detail, as I’m not quite sure what might be going wrong here. As soon as I’ll have an update, I’ll edit this reply and shoot you a PM as well :slight_smile:

As for the fields in the example i provided, the ID refers to a User within the account, as the column is a Person column. Those will always use User IDs in the platform itself, and you can query the User IDs of your account using our API. One other way of getting those quickly would be opening the specific user profile, as the link would display the User ID as well:

image

The kind will show the column type - the kind of a column can sometimes differ from the column ID or Column Name. For example, the “kind” value of the Time Tracking column will be “duration” while the ID can be something like duration1. Does that make sense?

I will look for a working example that I can provide here in the meantime. :slight_smile:

-Alex

Thanks Alex,
I was not aware that Persons or People was a column type, which led to some confusion.
Thanks for that context though.

For the working example can it contain multiple columns with a number, text, and status column types. This would help greatly as there has been a large amount of confusion with some of the syntax required as many of my attempts get the same 500 error that lacks a detailed explanation of the error.

@Eric_MSI

Of course! Have you had a chance to review our quickstart tutorial by the way? It should provide a lot of insight into how queries and mutations work on our side of things, and the example provided of creating an item with column values could provide a bit more context into how things work. If you get that right, using change_multiple_column_values should feel quite similar:

API Quickstart Tutorial - Python

-Alex

@AlexSavchuk
The link you posted is actually where I started. I used that to get my queries working to start to test using the API to grab information from the board.
The issues with Multiple column changes which I am still trying to find the cause of, which I believe results from the syntax I used for adding multiple columns types since all examples in the community boards and your documentations for multiple column changes have only 1 column being changed at at time.
I was also wondering if there are limits to the number of columns I can change at once? My example has 3 columns getting changed but my script changes over a dozen at once or if there are issues using ‘single quotations’ vs “double” (such as only use single for the JSON)

Another possible issue i noticed was at the end of the JSON

) { id } }

The example in


uses

) {updated_at }}

Is there documentation for the set formatting of this? I want to confirm for future scripts that I am adding this correctly.