Column Value Exception Error on Text Column but appears to be structured correctly

I am trying to create a new item with column values populated, but the API is throwing an error. I can’t figure out what I am doing wrong here. This is my code:

 $query = 'mutation ($myItemName: String!, $columnVals: JSON!) { 
 create_item (board_id:XXXXXXXX, item_name:$myItemName, 
 column_values:$columnVals) { id } }';
 $vars = ['myItemName' => 'Test Veterinary Hospital', 
     'columnVals' => json_encode([
     'status' => ['label' => 'Agency'], 
     'text' => ['text' => 'Test Practice Management System'],
     'text7' => ['text' => 'https://example.com/'],
     'text6' => ['text' => 'Test Name'],
     'text37' => ['text' => 'Email'],
     'text1' => ['text' => 'test@example.com'],
     'text2' => ['text' => '555-555-5555'],
     'text3' => ['text' => '333-333-3333'],
     'text8' => ['text' => 'Address Info'],
     'text4' => ['text' => 'Yes'],
     'text87' => ['text' => 'No'],
     'date' => ['date' => '2023-08-27'],
    'date9' => ['date' => '2023-08-28'],
     'text17' => ['text' => '$1200'],
     'text71' => ['text' => 'Name Here'],
     'text86' => ['text' => 'Some notes here!']

 ])];

 $data = @file_get_contents($apiUrl, false, stream_context_create([
  'http' => [
  'method' => 'POST',
  'header' => $headers,
  'content' => json_encode(['query' => $query, 'variables' => $vars]),
  ]
 ]));
 $responseContent = json_decode($data, true);

 echo json_encode($responseContent);

Here is the error I’m receiving:

{“error_code”:“ColumnValueException”,“status_code”:200,“error_message”:“invalid value, please check our API documentation for the correct data structure for this column. https://developer.monday.com/api-reference/docs/change-column-values”,“error_data”:{“column_value”:“{"text"=>"Test Practice Management System"}”,“column_type”:“TextColumn”}}

This is the column structure when I view it from the API:

[2] => Array
(
[archived] =>
[id] => text
[pos] =>
[settings_str] => {}
[title] => Practice Management System
[type] => text
[width] => 297
)

I’m not seeing an issue with my code above?

1 Like

Hi @adouglas_ivet,

If you remove that line, the rest works?

Hello there @adouglas_ivet,

I believe you might not be passing the values using the correct format.

I am not sure about PHP (I think it is PHP), but here is an example for JS:

 let vars = {
   "columnVals" : JSON.stringify({
	 "status" : {"label1" : "Done"},
	 "date0" : {"date2" : "1993-08-27"},
     "text4": "My text"
   })
 };

You can check the correct format for each column here!

Please let me know if that helps!!

When I remove that line, I just get another error message:

{“error_code”:“ColumnValueException”,“status_code”:200,“error_message”:“invalid value, please check our API documentation for the correct data structure for this column. https://developer.monday.com/api-reference/docs/change-column-values”,“error_data”:{“column_value”:“{"text"=>"https://example.com/"}”,“column_type”:“TextColumn”}}

I must not be formatting these correctly, but there are really no good examples of how to format these in the API docs. I have no idea what I’m doing wrong here. I feel like I’m setting this up similar to how the example is here: https://support.monday.com/hc/en-us/articles/360013465659-API-Quickstart-Tutorial-PHP under “Creating a new item with column values populated”

Hey Matias, I am formatting these just like the example here:

Under “Creating a new item with column values populated”.

The example given is:

<?php $query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:YOUR_BOARD_ID, item_name:$myItemName, column_values:$columnVals) { id } }'; $vars = ['myItemName' => 'Hello world!', 'columnVals' => json_encode([ 'status' => ['label' => 'Done'], 'date4' => ['date' => '1993-08-27'] ])]; $data = @file_get_contents($apiUrl, false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => $headers, 'content' => json_encode(['query' => $query, 'variables' => $vars]), ] ])); $responseContent = json_decode($data, true); echo json_encode($responseContent); ?>

My code is:
$vars = [‘myItemName’ => ‘Test Veterinary Hospital’,
‘columnVals’ => json_encode([
‘status’ => [‘label’ => ‘Agency’],
‘text’ => [‘text’ => ‘Test Practice Management System’],
‘text7’ => [‘text’ => ‘https://example.com/’],
‘text6’ => [‘text’ => ‘Test Name’],
‘text37’ => [‘text’ => ‘Email’],
‘text1’ => [‘text’ => ‘test@example.com’],
‘text2’ => [‘text’ => ‘555-555-5555’],
‘text3’ => [‘text’ => ‘333-333-3333’],
‘text8’ => [‘text’ => ‘Test address’],
‘text4’ => [‘text’ => ‘Yes’],
‘text87’ => [‘text’ => ‘No’],
‘date’ => [‘date’ => ‘2023-08-27’],
‘date9’ => [‘date’ => ‘2023-08-28’],
‘text17’ => [‘text’ => ‘$1200’],
‘text71’ => [‘text’ => ‘Alex Douglas’],
‘text86’ => [‘text’ => ‘Some notes here!’]
])];

I’ve checked the column IDs and types and they match up to what I have in the code. Is there someone with Monday that is familiar with PHP that could help out with this, or are we just on our own to figure out how to use the API with a particular language?

I tried reading up on the docs here: Column Types Reference

But I’m not really sure what I’m doing wrong even after reading through this.

The thing is, when I comment out every single line except for the line for the status column, it works:

$query = ‘mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:XXXXX, item_name:$myItemName, column_values:$columnVals) { id } }’;
$vars = [‘myItemName’ => ‘Test Veterinary Hospital’,
‘columnVals’ => json_encode([
‘status’ => [‘label’ => ‘Agency’]
//‘text’ => [‘text’ => ‘Test Practice Management System’],
//‘text7’ => [‘text’ => ‘https://example.com/’],
//‘text6’ => [‘text’ => ‘Test Name’],
//‘text37’ => [‘text’ => ‘Email’],
//‘text1’ => [‘text’ => ‘test@example.com’],
//‘text2’ => [‘text’ => ‘555-555-5555’],
//‘text3’ => [‘text’ => ‘333-333-3333’],
//‘text8’ => [‘text’ => ‘Test Address’],
//‘text4’ => [‘text’ => ‘Yes’],
//‘text87’ => [‘text’ => ‘No’],
//‘date’ => [‘date’ => ‘2023-08-27’],
//‘date9’ => [‘date’ => ‘2023-08-28’],
//‘text17’ => [‘text’ => ‘$1200’],
//‘text71’ => [‘text’ => ‘TEST’],
//‘text86’ => [‘text’ => ‘Some notes here!’]
])];

So I’m definitely not passing the values using the correct format, but I just can’t figure out what exactly the correct format is for text columns if I’m using PHP …

For instance this line:

‘text7’ => [‘text’ => ‘https://example.com/’],

Here is what the column structure is when I query the structure:

[3] => Array
(
[archived] =>
[id] => text7
[pos] =>
[settings_str] => {}
[title] => Practice Website
[type] => text
[width] => 198
)

So the ID of that column is “text7”.

Again, this line in my code works: ‘status’ => [‘label’ => ‘Agency’]

The column structure for this one is:

[1] => Array
(
[archived] =>
[id] => status
[pos] =>
[settings_str] => {“done_colors”:[1],“color_mapping”:{“2”:15,“3”:6,“6”:3,“10”:156,“15”:2,“156”:10},“labels”:{“0”:“Full Service”,“1”:“Agency +Analytics”,“2”:“Agency”,“3”:“Agency + HR \u0026 Team”,“4”:“Analytics + HR \u0026 Team”,“6”:“Analytics”,“7”:“HR \u0026 Team”,“8”:“Digital”,“9”:“HR On-Call”,“10”:“Other”},“labels_positions_v2”:{“0”:0,“1”:2,“2”:1,“3”:3,“4”:5,“5”:4,“6”:6,“7”:7,“8”:8,“9”:9,“10”:10},“labels_colors”:{“0”:{“color”:“#fdab3d”,“border”:“#E99729”,“var_name”:“orange”},“1”:{“color”:“#00c875”,“border”:“#00B461”,“var_name”:“green-shadow”},“2”:{“color”:“#9CD326”,“border”:“#89B921”,“var_name”:“lime-green”},“3”:{“color”:“#037f4c”,“border”:“#006B38”,“var_name”:“grass-green”},“4”:{“color”:“#a25ddc”,“border”:“#9238AF”,“var_name”:“purple”},“6”:{“color”:“#0086c0”,“border”:“#3DB0DF”,“var_name”:“blue-links”},“7”:{“color”:“#579bfc”,“border”:“#4387E8”,“var_name”:“bright-blue”},“8”:{“color”:“#CAB641”,“border”:“#C0AB31”,“var_name”:“mustered”},“9”:{“color”:“#FFCB00”,“border”:“#C0AB1B”,“var_name”:“yellow”},“10”:{“color”:“#9D99B9”,“border”:“#9D99B9”,“var_name”:“purple_gray”}}}
[title] => Service Level
[type] => color
[width] => 192
)

ID is “status”, and this is how I’m formatting it in my code (which works for this line):

‘status’ => [‘label’ => ‘Agency’]

I’m just not getting why these lines aren’t working for a text column with the correct ID:

‘text’ => [‘text’ => ‘Test Practice Management System’],
‘text7’ => [‘text’ => ‘https://example.com/’],
‘text6’ => [‘text’ => ‘Test Name’],
‘text37’ => [‘text’ => ‘Email’],
‘text1’ => [‘text’ => ‘test@example.com’],
‘text2’ => [‘text’ => ‘555-555-5555’],
‘text3’ => [‘text’ => ‘333-333-3333’],
‘text8’ => [‘text’ => ‘Test Address’],
‘text4’ => [‘text’ => ‘Yes’],
‘text87’ => [‘text’ => ‘No’],
‘text17’ => [‘text’ => ‘$1200’],
‘text71’ => [‘text’ => ‘Alex Douglas’],
‘text86’ => [‘text’ => ‘Some notes here!’]

I’ve tried formatting these like this:

‘text’ => [‘Test Practice Management System’],
‘text7’ => [‘https://example.com/’],
‘text6’ => [‘Test Name’],
‘text37’ => [‘Email’],
‘text1’ => [‘test@example.com’],
‘text2’ => [‘555-555-5555’],
‘text3’ => [‘333-333-3333’],
‘text8’ => [‘Test Address’],
‘text4’ => [ ‘Yes’],
‘text87’ => [‘No’],
‘text17’ => [‘$1200’],
‘text71’ => [‘Alex Douglas’],
‘text86’ => [‘Some notes here!’]

but get basically the same error message.

I’ve figured out the correct format, so we are all good here. It was a simple mistake in my PHP. Here is the correct format for anyone who sees this!

//CREATE ITEM WITH COLUMN VALUES

$query = ‘mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:XXXXX, item_name:$myItemName, column_values:$columnVals) { id } }’;
$vars = [‘myItemName’ => ‘Test 2 Veterinary Hospital’,
‘columnVals’ => json_encode([
‘status’ => [‘label’ => ‘Agency’],
‘text’ => ‘Test Practice Management System’,
‘text7’ => ‘https://example.com/’,
‘text6’ => ‘Test Name’,
‘text37’ => ‘Email’,
‘text1’ => ‘test@example.com’,
‘text2’ => ‘555-555-5555’,
‘text3’ => ‘333-333-3333’,
‘text8’ => ‘TEST ADDRESS’,
‘text4’ => ‘Yes’,
‘text87’ => ‘No’,
‘date’ => [‘date’ => ‘2023-08-27’],
‘date9’ => [‘date’ => ‘2023-08-28’],
‘text17’ => ‘$1200’,
‘text71’ => ‘Test’,
‘text86’ => ‘Some notes here!’
])];

1 Like

Hi @adouglas_ivet,

I’m happy to hear all is working for you now!

Thanks for sharing your example with the community.