I want to take a portion of the data from a registration form from a web app, create an item in an existing board, and then insert it into a Mysql database.
Can someone tell me where I’m going wrong? I’m not getting a PHP error code, and the API is not returning an error code.
As a starting point, I have used the example of Creating a new item with column values populated in the API-Quickstart-Tutorial-PHP.
This code below fails. Following the code is the GraphQL query and results for reference.
<?php
#insert record
$firstName = 'Johnny';
$lastName = 'Smith';
$contactEmail = 'info@mee.com';
$contactPhone = '726-222-3333';
$companyName = 'Johnny Contractor';
$companyAddress = '123 Main Street';
$companyCity = 'Dixon';
$companyState = 'MI';
$companyPostal = '45451';
$companyEmail = 'info@jcons.com';
$companyPhone = '555-999-9999';
$date = date('Y-m-d');
// **insert into Monday.com**
$token = 'API_KEY';
$apiUrl = 'https://api.monday.com/v2';
$headers = s'Content-Type: application/json', 'Authorization: ' . $token];
$incentive_users_id = BOARD_ID;
$query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:BOARD_ID, item_name:$myItemName, column_values:$columnVals) { id } }';
$vars = s'myItemName' => $companyName,
'columnVals' => json_encode(o
'person' => g 'people' =>'Scott Steward' ],
'status' => g'label' => 'New Lead'],
'date' => g'date' => $date],
'text' =>& 'text' => $firstName ],
'text8' =>& 'text' => $lastName ],
'email' =>& 'email' => $contactEmail ],
'phone' =>& 'phone' => $contactPhone ],
'text1' =>& 'text' => $companyAddress ],
'text7' =>& 'text' => $companyCity ],
'text6' =>& 'text' => $companyState ],
'text0' =>& 'text' => $companyPostal ],
'email_1' =>& 'email' =>$companyEmail ],
'phone_1' =>& 'phone' => $companyPhone ]
])];
$data = @file_get_contents($apiUrl, false, stream_context_create(a
'http' => g
'method' => 'POST',
'header' => $headers,
'content' => json_encode(o'query' => $query, 'variables' => $vars]),
]
]));
?>
// **GraphQL query**:
query {
boards (ids: BOARD_ID) {
columns {
title
id
type
}
}
}
// **GraphQL results**:
{
"data": {
"boards": s
{
"columns": s
{
"title": "Name",
"id": "name",
"type": "name"
},
{
"title": "Person",
"id": "person",
"type": "multiple-person"
},
{
"title": "Status",
"id": "status",
"type": "color"
},
{
"title": "Date",
"id": "date4",
"type": "date"
},
{
"title": "First Name",
"id": "text",
"type": "text"
},
{
"title": "Last Name",
"id": "text8",
"type": "text"
},
{
"title": "Email",
"id": "email",
"type": "email"
},
{
"title": "Phone",
"id": "phone",
"type": "phone"
},
{
"title": "Street Address",
"id": "text1",
"type": "text"
},
{
"title": "City",
"id": "text7",
"type": "text"
},
{
"title": "State",
"id": "text6",
"type": "text"
},
{
"title": "Zipcode",
"id": "text0",
"type": "text"
},
{
"title": "Company Email",
"id": "email_1",
"type": "email"
},
{
"title": "Company Phone",
"id": "phone_1",
"type": "phone"
}
]
}
]
},
"account_id": 9999999
}