Post request for changing column value from expressjs

Hey there!

I’ve a really bad time wrapping my head around this… I’m trying to change a column value from a post request. It’s formed as follows:

            var query = `mutation change_column_value($board_id: Int!, $item_id: Int!, $column_id: String!, $value: String!) {
                          change_column_value(board_id: $board_id, item_id: $item_id, column_id: $column_id, value: $value)
                            {id}}`

And these are my variables:

            var board_id = 3395274995;
            var item_id = req.body.eventId;
            var column_id = "text71";
            var value = "Test";

And I’m getting this response:

'Type mismatch on variable $value and argument value (String! / JSON!)'

I just don’t get it, column_id is a String and that seems to work perfectly but the value throws an error. The field is a simple text field, so it should be of type String or am I missing something?

Except the the value needs to be stringified :slight_smile:

Thanks again for your support Bas :smiling_face:

here is where I get stuck… This request works fine:

{"query":"mutation{ change_column_value (item_id: 3395473805, board_id: 3395274995, column_id: \"numbers7\", value: \"2\") { id } }"}
{

This one doesn’t:

{"query":"mutation{ change_column_value (item_id: 3395473805, board_id: 3395274995, column_id: \"text6\", value: \"Test\") { id } }"}

Now, do I need to double escape a text value or what am I missing? How should the text value look like to be accepted?

Thanks again for helping out here!

Please check the API docs for column references at Text and Numbers

Looks like you are mixing Simple strings and JSON formatted strings (these need to be stingified)

1 Like

Uuh, I got it. Yes, I mixed and matched the formatting. For anybody finding this. I’ve adapted the example in the text API docs:

            var requestBody = JSON.stringify({
                query: "mutation ($myBoardId:Int!, $myItemId:Int!, $myColumnValues:JSON!) { change_multiple_column_values(item_id:$myItemId, board_id:$myBoardId, column_values: $myColumnValues) { id }}",
                variables: JSON.stringify({
                    "myBoardId": MY_BOARD_ID,
                    "myItemId": MY_ITEM_ID,
                    "myColumnValues": `{\"text64\": \"${MY_TEXT}\"}`
            })

Thanks a lot Bas, great help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.