Dheeraj
January 30, 2023, 10:08pm
1
I was trying to make an post API call to update value on the Monday board but it is throwing an error in Node.js
var action = “mutation{change_column_value (board_id:3258333017, item_id:785444200, column_id:“text”, value:“board1”){ id }}”;
fetch (“https://api.monday.com/v2” , {
method: ‘post’,
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’ : ‘’
},
body: JSON.stringify({
‘query’ : action
})
})
.then(res => res.json())
.then(res => console.log(JSON.stringify(res, null, 2)));
When I try to do this it is throwing an error:
{
“error_message”: “809: unexpected token at ‘board1’”,
“status_code”: 500
}
can anyone help me with this?
1 Like
Hello there @Dheeraj ,
You need to use change_simple_column_value instead of change_column_value for this one
Let me know if you have any other questions!
Cheers,
Matias
2 Likes
mutation{change_simple_column_value (board_id:98333017, item_id:9851336900, column_id:"color", value:“{"label":"Good"}”){ id }}
How should I give the value in this case (bold part) ?. This works fine in graphQL console but not working in nodeJS.
It is throwing me this error:-
mutation{change_simple_column_value (board_id:3858426017, item_id:3858426300, column_id:“color”, value:“{“label”:“Ok”}”){ id }}
{
errors: [
{
message: ‘Parse error on “:” (STRING) at [1, 110]’,
locations: [Array]
}
],
account_id: 8165721
}
@Dheeraj
As you are using change_simple_column_value
you don’t need to specific the “Label”, you only need to pass the string as the variable.
I.e:
mutation { change_simple_column_value (board_id:3858426017, item_id:3858426300, column_id:“color”, value:“Ok”) { id }}
You can view the column reference here - Status
You can also include the create_labels_if_missing: true
if you need to create new labels values if they don’t exist, otherwise an error will be thrown if the label has not already been created.
If you would like to provide a JSON value, I believe the issue is that it isn’t correctly escaped, it should be:
mutation { change_column_value (board_id:3858426017, item_id:3858426300, column_id:“color”, “{\“label\”:\“Ok\”}”) { id }}
Take note of the different mutations being change_column_value
for JSON and change_simple_column_value
text string
1 Like
Working thank you so much.
Hello @Dheeraj ,
I am glad this is working now!
Thank you @mitchell.hudson for the help here
Cheers,
Matias
Dheeraj
February 3, 2023, 11:04pm
7
Hi
I’m trying to update multiple columns on the board using
let addNewURLDataQuery = mutation {change_multiple_column_values (board_id: 435872999 item_id: ${item_id}, column_values: "{"color": "Ok", "text9": "b"}") { id } }
color, text9 are column id’s
But it is throwing parse error
{
errors: [
{
message: ‘Parse error on ": " (STRING) at [1, 107]’,
locations: [Array]
}
],
account_id: 4569729
}
How should I format column_values in this case?
dipro
February 8, 2023, 4:19pm
9
Try escaping the inner quotes in your column_values
argument. The inner quotes must be preceded with a \
to differentiate them from the outer ones. Without them, the string will not be parsed correctly.
Try this as the argument instead:
column_values: "{\"color\": \"Ok\", \"text9\": \"b\"}")