Hi,
(Pardon if this has been raised before but as far as i can search, can’t find a similar posting so here goes…)
I’m having a problem with create_item mutation.
It works on localhost (tried PHP7.2 and PHP7.4) and returns a proper id
but when we are running it in our test env server (cpanel with apache + PHP7.2.32), only “null” is returned.
I’m starting to doubt that it is code related and perhaps related to PHP setup? Maybe we missed a prerequisite somewhere. Any help would be appreciated (Thanks in advance)
I tried logging the returned JSON to compare [redacted some info]:
LOCALHOST:
Array ( [myItemName] => ignoreme1235 [columnVals] => {"numbers4":"1","status_1":{"label":"XXX"},"package":{"label":"XXX"},"task_date_1":{"date":"2020-07-31"},"client_name5":"ignoreme1235","client_name50":"ignoreme1235","phone":{"phone":"","countryShortName":"US"},"mobile_phone":{"phone":"","countryShortName":"US"},"primary03":null,"business_type":"ignoreme1235, ignoreme1235, ignoreme1235, ignoreme1235, DE, 12344","setup_fee":"999.00","eft":"499.00","sold_by":{"label":"XXX"},"long_text":{"text":"ignoreme1235"},"numbers":"31","text8":"20200731224555"} ) {"data":{"create_item":{"id":"99999999"}},"account_id":9999999}
SERVER:
Array ( [myItemName] => mondayfunday1234 [columnVals] => {"numbers4":"1","status_1":{"label":"XXX"},"package":{"label":"XXX"},"task_date_1":{"date":"2020-07-31"},"client_name5":"mondayfunday1234","client_name50":"mondayfunday1234","phone":{"phone":"","countryShortName":"US"},"mobile_phone":{"phone":"","countryShortName":"US"},"primary03":null,"business_type":"mondayfunday1234, mondayfunday1234, mondayfunday1234, mondayfunday1234, CO, 12345","setup_fee":"999.00","eft":"499.00","sold_by":{"label":"XXX"},"long_text":{"text":"mondayfunday1234"},"numbers":"31","text8":"20200731231626"} ) null
relevant Laravel PHP code:
`
$MONDAY_BOARD_ID = env(‘MONDAY.COM.BOARD_ID’);
$MONDAY_GROUP_ID = env(‘MONDAY.COM.GROUP_ID’);
$MONDAY_TOKEN = env(‘MONDAY.COM.TOKEN’);
$MONDAY_API_URL = env(‘MONDAY.COM.API_URL’);
$headers = ['Content-Type: application/json', 'Authorization: ' . $MONDAY_TOKEN];
$query = 'mutation ($myItemName: String!, $columnVals: JSON!) {
create_item (
board_id:' . $MONDAY_BOARD_ID .',
group_id:' . $MONDAY_GROUP_ID .',
item_name:$myItemName,
column_values:$columnVals) { id } }';
$item_name = $REDACTED_VAR;
$salesperson_fullname = $REDACTED_VAR;
$agreement_no = $REDACTED_VAR;
$vars = [
'myItemName' => $item_name,
'columnVals' => json_encode([
"numbers4" => $REDACTED_VAR,
"status_1" => ['label' => $REDACTED_VAR],
"package" => ['label' => $REDACTED_VAR],
"task_date_1" => ['date' => date("Y-m-d")],
"client_name5" => $REDACTED_VAR,
"client_name50" => $REDACTED_VAR,
"phone" => ["phone" => $REDACTED_VAR, "countryShortName"=>"US"],
"mobile_phone" => ["phone" => $REDACTED_VAR, "countryShortName"=>"US"],
"primary03" => $REDACTED_VAR,
"business_type" => $REDACTED_VAR,
"setup_fee" => $REDACTED_VAR,
"eft" => $REDACTED_VAR,
"sold_by" => ["label" => $salesperson_fullname],
"long_text" => ["text" => $REDACTED_VAR],
"numbers" => date('d'),
"text8" => $agreement_no,
])
];
\Log::debug("monday query vars: " . print_r($vars));
$data = @file_get_contents($MONDAY_API_URL, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode(['query' => $query, 'variables' => $vars]),
]
]));
$responseContent = json_decode($data, true);
`