Failed to insert record to Monday.com via api v2

Hey @Hilary - we have a quickstart tutorial for using PHP to make API queries.

One thing I will recommend from seeing previous users use PHP for this - I would recommend maintaining any variables within the $vars object so that json_decode will run on them. You can see an example of what I mean on the last example in the tutorial page:

<?php
$query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:YOUR_BOARD_ID, item_name:$myItemName, column_values:$columnVals) { id } }';
$vars = ['myItemName' => 'Hello world!', 
  'columnVals' => json_encode([
    'status' => ['label' => 'Done'], 
    'date4' => ['date' => '1993-08-27']
])];

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

-Daniel

1 Like

Thank you very much.

1 Like

Thank you for everyone’s help. We did some more testing again and had some success. We will continue to do the testing. Hopefully it will work well.

1 Like

Glad to hear @Hilary! Let us know if you have any other questions :slight_smile:

-Daniel

So far, it’s good. It’s working well. Thanks.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.