Having a GraphQL parsing error:

Trying to update Monday,con columns using PHP file and everything thin gh I;ve tried, and I’ve enlisted Gemini AI, fails. Any ideas on how rto make this update work?

I send: $query = 'mutation $query = ‘mutation updateItemData{change_multiple_column_values(board_id:’ . $boardId . ‘,item_id:’ . $itemId . ‘,column_values:’ . $formattedColumnValuesForGraphQL . ‘){id name column_values{id value type}}}’;

Which produces this mutation:

mutation updateItemData {
change_multiple_column_values (
board_id: 1234567890,
item_id: 1987654320,
column_values: {
status: “{"label":"TEST ONLY"}”,
notes: “testing”
}
) {
id
name
column_values {
id
value
type
}
}
}

and is returning this error:

[26-May-2025 00:10:10 UTC] API received column_values from frontend: {“status”:{“label”:“TEST ONLY”},“notes”:“testing”}

[26-May-2025 00:10:10 UTC] Monday.com GraphQL Query Sent: {“query”:“mutation updateItemData{change_multiple_column_values(board_id:8696866548,item_id:9224943470,column_values:{"status":"{\"label\":\"TEST ONLY\"}","notes":"testing"}){id name column_values{id value type}}}”}

[26-May-2025 00:10:10 UTC] Monday.com API Error (HTTP 400): {“errors”:[{“message”:“parsing error: syntax error: expected R_CURLY, got "status"”,“locations”:[{“line”:1,“column”:109}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected R_PAREN, got "status"”,“locations”:[{“line”:1,“column”:109}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected R_CURLY, got "status"”,“locations”:[{“line”:1,“column”:109}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected definition”,“locations”:[{“line”:1,“column”:109}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:117}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected definition”,“locations”:[{“line”:1,“column”:118}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected definition”,“locations”:[{“line”:1,“column”:146}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:153}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected definition”,“locations”:[{“line”:1,“column”:154}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:163}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:164}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:203}],“extensions”:{“code”:“PARSING_ERROR”}}]}

[26-May-2025 00:10:10 UTC] Failed to update Monday.com item. Result: {“error”:“Monday.com API Error”,“http_code”:400,“details”:{“errors”:[{“message”:“parsing error: syntax error: expected R_CURLY, got "status"”,“locations”:[{“line”:1,“column”:109}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected R_PAREN, got "status"”,“locations”:[{“line”:1,“column”:109}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected R_CURLY, got "status"”,“locations”:[{“line”:1,“column”:109}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected definition”,“locations”:[{“line”:1,“column”:109}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:117}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected definition”,“locations”:[{“line”:1,“column”:118}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected definition”,“locations”:[{“line”:1,“column”:146}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:153}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected definition”,“locations”:[{“line”:1,“column”:154}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:163}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:164}],“extensions”:{“code”:“PARSING_ERROR”}},{“message”:“parsing error: syntax error: expected a StringValue, Name or OperationDefinition”,“locations”:[{“line”:1,“column”:203}],“extensions”:{“code”:“PARSING_ERROR”}}]}}

[26-May-2025 00:10:10 UTC] Failed to update Monday.com item for client ID: 29. Item ID: 9224943470. Monday API response: false

Hi @mark.stout, there is an error in parsing JSON.

Try to stringify the column_values shown below.
Current → {
status: “{“label”:“TEST ONLY”}”,
notes: “testing”
}

Convert it to JSON string(NEW) → JSON.stringify({
status: “{“label”:“TEST ONLY”}”,
notes: “testing”
})

I use Javascript, in your case please use appropriate JSON library in PHP.

You can also read monday official documentation on changing multiple column values here.

Do you see anything I’m doing leading up to the query?

public function updateItem($boardId, $itemId, $columnValues = []) {
    $column_value_pairs = []; 
    foreach ($columnValues as $colId => $colValue) {
        $colIdEscaped = addslashes($colId);

        $valueForGraphQL = ''; 
        // --- Logic to prepare the value based on its type and Monday.com's expectation ---
        if ($colId === 'status' || $colId === 'color_mknymdsp') {
            $plainValue = ''; 
            if (is_array($colValue) && isset($colValue['label'])) {
                $plainValue = $colValue['label'];
            } elseif (is_string($colValue)) {
                $plainValue = $colValue;
            }   
            $valueForGraphQL = '"' . addslashes($plainValue) . '"';
        } elseif (is_string($colValue)) {
            $valueForGraphQL = '"' . addslashes($colValue) . '"';
        } elseif (is_array($colValue) || is_object($colValue)) {
            $jsonEncodedValue = json_encode($colValue);
            if ($jsonEncodedValue === false) {
                error_log('JSON encoding error for complex column value (' . $colId . ') in updateItem: ' . json_last_error_msg());
                return false;
            }   
            $valueForGraphQL = '"' . addslashes($jsonEncodedValue) . '"';
        } else {
            $valueForGraphQL = 'null';
        }   
        // --- End value preparation logic ---

        $column_value_pairs[] = '"' . $colIdEscaped . '":' . $valueForGraphQL;
    }   
    $formattedColumnValuesForGraphQL = '{' . implode(', ', $column_value_pairs) . '}';


    // Use change_multiple_column_values as per Monday.com AI and successful Playground test
    $query = 'mutation updateItemData{change_multiple_column_values(board_id:' . $boardId . ',item_id:' . $itemId . ',column_values:' . $formattedColumnValuesForGraphQL . '){id name column_values{id value type}}}';

I’ve said it before and I’ll say it again.

Use graphql variables.

It takes the pain out of escaping JSON strings. With variables you’ll only ever have to escape any values once.

Most of the questions on graphql on this forum are from incorrectly escaping JSON. All documentation examples really should be doing the same so that people start from a better place. Concatenating strings is not the right way to go.

I’ve given countless examples previously, so look and choose one, or Google it.