I can insert an item if it looks like this
$mutationQuery = 'mutation {
create_item(
board_id: ' . $boardId . ',
group_id: "' . $groupId . '",
item_name: "' . $cursus . '"
) {
id
}
}';
but when i try to insert any value to another column i always get an error, am i doing something wrong?. this the code i have
$mutationQuery = 'mutation {
create_item(
board_id: ' . $boardId . ',
group_id: "' . $groupId . '",
item_name: "' . $cursus . '",
column_values: {
"lange_tekst": { "text": "'.$cursus.'" }
}
) {
id
}
}';
this is my full code if you want to know
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$token = 'MY_API';
$apiUrl = 'https://api.monday.com/v2';
$headers = ['Content-Type: application/json', 'Authorization: ' . $token];
$cursus = 'lolinit';
$boardId = '5554649549';
$groupId = 'topics';
// Prepare mutation query
$mutationQuery = 'mutation {
create_item(
board_id: ' . $boardId . ',
group_id: "' . $groupId . '",
item_name: "' . $cursus . '",
column_values: {
"lange_tekst": { "text": "'.$cursus.'" }
}
) {
id
}
}';
$data = @file_get_contents($apiUrl, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode(['query' => $mutationQuery]),
]
]));
$responseContent = json_decode($data, true);
// Handle the response as needed
if (isset($responseContent['data']['create_item']['id'])) {
echo 'Item created successfully!';
} else {
echo 'Error creating item.';
if (isset($responseContent['errors'])) {
echo 'API Error: ' . print_r($responseContent['errors'], true);
echo '<pre>';
print_r($responseContent);
echo '</pre>';
}
}
}