Skip to main content

Hello, I use monday API from a while now, and suddenly an error has appears (on the 29/03) after days of good work.

I have test many possibility of queries but I can’t figured it out.

There is my query :

$query =
            'mutation {
            create_item ( board_id: 409788845, group_id: "topics", item_name: "TEST MODULE",
                column_values: "{
                    \\"texte5\\" : \\"test tex\\",
                    \\"texte\\" : \\"Dev\\",
                    \\"person\\" : \\"2556545674\\",
                    \\"connecter_les_tableaux7\\" : {\\"item_ids\\" : [14564564960]},
                    \\"date\\" : {\\"date\\" : \\"2023-03-30\\", \\"time\\" : \\"08:49:02\\"},
                    \\"date6\\" : {\\"date\\" : \\"2023-03-30\\", \\"time\\" : \\"10:25:00\\"},
                    \\"chiffres\\" : \\"1.6\\",
                    \\"chiffres0\\" : \\"372847239\\"
                }")  {
                    id
                }
            }';

This return me this error :

{
    "errors": [
        {
            "message": "Parse error on bad Unicode escape sequence: \\"{\\\\n                    \\\\\\\\\\\\\\"texte5\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"test tex\\\\\\\\\\\\\\",\\\\n                    \\\\\\\\\\\\\\"texte\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"Dev\\\\\\\\\\\\\\",\\\\n                    \\\\\\\\\\\\\\"person\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"2556545674\\\\\\\\\\\\\\",\\\\n                    \\\\\\\\\\\\\\"connecter_les_tableaux7\\\\\\\\\\\\\\" : {\\\\\\\\\\\\\\"item_ids\\\\\\\\\\\\\\" : [14564564960]},\\\\n                    \\\\\\\\\\\\\\"date\\\\\\\\\\\\\\" : {\\\\\\\\\\\\\\"date\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"2023-03-30\\\\\\\\\\\\\\", \\\\\\\\\\\\\\"time\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"08:49:02\\\\\\\\\\\\\\"},\\\\n                    \\\\\\\\\\\\\\"date6\\\\\\\\\\\\\\" : {\\\\\\\\\\\\\\"date\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"2023-03-30\\\\\\\\\\\\\\", \\\\\\\\\\\\\\"time\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"10:25:00\\\\\\\\\\\\\\"},\\\\n                    \\\\\\\\\\\\\\"chiffres\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"1.6\\\\\\\\\\\\\\",\\\\n                    \\\\\\\\\\\\\\"chiffres0\\\\\\\\\\\\\\" : \\\\\\\\\\\\\\"372847239\\\\\\\\\\\\n                }\\" (error) at [3, 32]",
            "locations": [
                {
                    "line": 3,
                    "column": 32
                }
            ]
        }
    ],

Here is how I send the data in PHP :

 $result = @file_get_contents($this->apiUrl, false, stream_context_create([
            'http' => [
                'method' => 'POST',
                'header' => $this->headers,
                'content' => json_encode(['query' => $query]),
            ]
        ]));

I understand that the error is at the beginning of the column_values but impossible to make work again.

Again I want to specify that my request were working before the 29 (I have tried with the exact data who works previously).

Could you take a look at this ?

Thanks.
Clement.

Just to double on this I have had some live software also stop working recently due to the same error, anyone know if this is an API change or what?


Hello everyone,

I have checked with the team and it looks like you might be seeing this errors because of a migration that was done on our end.

The new changes follow the GraphQL specifications more closely and patches lots of different gaps, just like strings with line endings.

To have a multiline string you need to use block strings """text""" , not "text".

You can also remove line endings from the query and keep it in one line.

You can also use GraphQL variables to put in any text as a JSON. It’s recommended to use this approach for big values, as this improves readability of queries.

I attached some examples of valid and invalid queries.

Please let me know if you have any questions!

Valid:

Valid:

Invalid:


Thanks for your reply.

Effectively, passing the variable as GraphQL variables fix the issues.

Here is an example in PHP if it can help somebody :

$query_update_item =
            'mutation($column: JSON!) {
                change_multiple_column_values ( item_id: '. $id .', board_id: '.$this->board_id.', column_values: $column )  {
                    id
                }
            }';

        $var = [
            'column' => '{
                    "texte5" : "'. $text .'",
                    "texte" : "'. $text1 .'",
                    "connecter_les_tableaux7" : {"item_ids" : ['. $timer->project_id .']},
                    "date" : {"date" : "'.$day_start.'", "time" : "'.$hour_start.'"},
                    "date6" : {"date" : "'.$day_end.'", "time" : "'.$hour_end.'"},
                    "chiffres" : "'. $chiffres .'",
                    "chiffres0" : "'. $chiffres0 .'"
                }'
        ];


        $result = @file_get_contents($this->apiUrl, false, stream_context_create([
            'http' => [
                'method' => 'POST',
                'header' => $this->headers,
                'content' => json_encode(['query' => $query_update_item, 'variables' => $var]),
            ]
        ]));

Hello again,

I am glad that worked!

Thank you for sharing this!

Cheers,
Matias