The others brought up a good point about stringifying your JSON and I really think that is the main problem as well. Since you’re using XMLHttpRequest rather than Monday’s API, the requirement is a bit different. Moving forward I recommend using JSON.stringify()
than try to figure out where to put the slashes and quotes. insert whohastimeforthat.gif
I believe you wanted to use it all in one line and stick your variables inside the query and not use variables, but unfortunately that’s not possible with changing column values as @supernova and @TMNXT-Dev have pointed out.
I have it working for XMLHttpRequest here:
The query:
const query = `mutation changeValues($board_id: Int!, $item_id: Int, $column_id: String!, $value: JSON!) {
change_column_value (board_id: $board_id, item_id: $item_id , column_id: $column_id, value: $value) {
id
}
}`
The variables:
//The JSON.stringify() your value way
const variables = {"board_id": boardId, "item_id": itemId, "column_id": "status", "value": JSON.stringify({index: 2})}
//Stringify the value yourself way:
const variables = {"board_id": boardId, "item_id": itemId, "column_id": "status", "value": "{\"index\": 2}"}
I’m not familiar with IIS, but I am a bit familiar with XMLHttpRequests as I use fetch more frequently, so I hope you can translate it to how you want, but this is how I have it working:
const xmlhttp = new XMLHttpRequest();
const theUrl = "https://api.monday.com/v2"
xmlhttp.open('POST', theUrl);
xmlhttp.setRequestHeader("Content-Type", "application/json")
xmlhttp.setRequestHeader("Authorization", token)
//Yep, stringify it again.
xmlhttp.send(JSON.stringify({query, variables}))
Hope that helps you get pass this issue! If not, let us know.