Noob question about email address format in create_item

I’m using the function below to submit a new registration but it always fails if I uncomment out the email entry. All the other fields are being passed over to monday without issues, just stuck on email right now and would appreciate any help.

      function send_to_monday($userr) {
        $board_id = xxxxxxxxxx;
        $api_key = '';

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

        $column_values = array(
            // Column values
        );

		$variables = array(
            'item_name' => $userr['fio'],
            'column_values' => json_encode([
			// 'email'=> ['email'=> $userr['email']],
            'text0'=> $userr['magent'],
			'text5'=> $userr['country'],
			'text50'=> $userr['town'],
			'text43'=> $userr['port'],
			'text3'=> $userr['skype'],
			'text10'=> $userr['about'],
			'phone'=> $userr['tel'],
			'text4'=> $userr['username'],
			'text9'=> $userr['password'],
			'country'=> ['countryCode'=> $userr['country']]

			])
        );

        $data = array(
            'query' => $query,
            'variables' => $variables
        );

        $headers = array(
            'Content-Type: application/json',
            'Authorization: '.$api_key
        );

        $ch = curl_init('https://api.monday.com/v2/');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

        $response = curl_exec($ch);
        curl_close($ch);

        // Handle response or errors here (if needed)
    }

    send_to_monday($userr);
    $ress = aj_user($userr);
        // End Monday.com API integration

You are required to include both the email and text keys in the mutation, even if the text is the email address itself.

'email' => ['email'=> $user['email'], 'text'=> $user['email']]

2 Likes

Thank you @codyfrisch !!

2 Likes