0

I am attempting to create a new item on a Monday board using the API with PHP, but I am receiving an error from the API. Here is my code:

 $query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item 
 (board_id:XXXXXXX, 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 Name'],
   '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);

This error is returned:

 {"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"}}

Here is the column id and structure when I query the API for that info:

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

As far as I can tell, everything is formatted correctly above, but I must be missing something simple.

Alex Douglas
  • 534
  • 1
  • 8
  • 21

1 Answers1

0

Try using plain strings for text columns i.e. instead of ['text' => 'Test Practice Management System'] use ['Test Practice Management System']

Moshe.z
  • 171
  • 2
  • 7