Monday.com 创建一个新项目,其中使用 API 和 PHP 填充列值

问题描述 投票:0回答:1

我尝试使用 API 和 PHP 在周一板上创建一个新项目,但我收到来自 API 的错误。这是我的代码:

 $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' => '[email protected]'],
   '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);

返回此错误:

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

这是我在 API 中查询该信息时的列 ID 和结构:

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

据我所知,上面的所有内容都格式正确,但我一定错过了一些简单的东西。

php api graphql monday.com
1个回答
0
投票

尝试对文本列使用纯字符串,即 代替 ['text' => '测试实践管理系统'] 使用 [‘测试实践管理系统’]

© www.soinside.com 2019 - 2024. All rights reserved.