Creating a new item with PERSON column values populated

Hello every one, I need some help please.
I use a simple board, an item is assigned to a group of person. This is the structure :

{“name”:“Thing to do”,“column_values”:[{“id":“person”,“type”:“multiple-person”,“text”:"user1@mydom.com, user2@mydom.com”},{“id”:“status”,“type”:“color”,“text”:“Done”},{“id”:“timeline”,“type”:“timerange”,“text”:“2022-09-19 - 2022-10-01”},{“id”:“texte8”,“type”:“long-text”,“text”:“Good job”}]}

I managed to folow the QuickStart PHP Api Guide and populate the main Label, the status and the last “text8” label.
But I can’t manage to populate the timeline column and most of all, the person column.
I think there is something about Person ID (I managed to find all the IDs).

I tried this :

$headers = ['Content-Type: application/json', 'Authorization: ' . $token];

$query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:XXXXXXXXX, item_name:$myItemName, column_values:$columnVals) { id } }';

$vars = ['myItemName' => 'Thing to do', 
  'columnVals' => json_encode([
    'status' => ['label' => 'Done'], 
	'person' => ['text' => 'user1@mydom.com'],
    'date4' => ['date' => '2022-09-15'],
	'texte8' => ['text' => 'Good job']
])];

$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);

I guess that the ‘date4’ should be replaced by the right ID,
and i suspect a wrong structure for “person”.

Anyone to help me with that simple code?
:pray:

:frowning: no one to help me with populating my person/people column?
I tried so many things and failed. I’m out of idea…
any help would be very appreciated

Hi @Pharamousse,

Welcome to the community! :rocket:

To update the People column, you should send either a simple string or a JSON string with the IDs of the people you want to add, for example:

"4616627, 4616435, 4616912"

or

"{\"personsAndTeams\":[{\"id\":4616627,\"kind\":\"person\"},{\"id\":4616666,\"kind\":\"person\"},{\"id\":51166,\"kind\":\"team\"}]}"

Hi Alessandra,
thank you for your reply, I already tried that and unfortunatly something went wrong.
This is what I get :

{"error_code":"ColumnValueException","status_code":200,"error_message":"Error GraphqlCustomExceptions::CorrectedValueException has occurred during simple column conversion","error_data":{"column_value":"{\"personsAndTeams\":[{\"id\":34975497,\"kind\":\"person\"},{\"id\":35050980,\"kind\":\"person\"}]}","column_type":"multiple-person"}} 

Here is my PHP Code


$headers = ['Content-Type: application/json', 'Authorization: ' . $token];

$query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:XXXXXXXX, item_name:$myItemName, column_values:$columnVals) { id } }';
$myCol = "{\"personsAndTeams\":[{\"id\":12345678,\"kind\":\"person\"},{\"id\":987654321,\"kind\":\"person\"}]}";

$vars = ['myItemName' => 'Thing to do', 
  'columnVals' => json_encode([
    'status' => ['label' => 'Attente'], 
	'person' => $myCol ,
	'date4' => ['date' => '2022-09-15'],
	'texte8' => ['text' => 'Well done']
])];

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

I feel like I’m close to something but it goes wrong whatever I try.

EUREKA !!
I got it !! :slight_smile: Thank you.

$myCol ="xxxxxxxx,yyyyyyyyyy";

It works very well,
THANK YOU SO MUCH

Hi @Pharamousse,

I’m happy to hear you query is working now! what did you do to fix it?