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?