Newbie Needs a Simple Answer

Hey everyone,
I’m just starting with the Monday API as a developer without being too familiar with the platform. I have what I thought was a simple task, but it turns out it’s a bit more challenging. I am simply trying to add a record to a table given name and phone number. In using the PHP samples I keep seeing something called “item_name”. My code works (sort of) but whatever I place in item_name goes in the first field and nothing appears in other fields even though I am also using “column_values”. I get no error code. Do I need to use a group_name or something like that? Code is below and any help would be appreciated.

$query = ‘mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:575799XXXX, item_name:$myItemName, column_values:$columnVals) { id } }’;
$vars = [‘myItemName’ => $name,
‘columnVals’ => json_encode([
‘Phone’ => [$phone]

    $ch = curl_init();

    $je = json_encode(['query' => $query, 'variables' => $vars]);

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $je);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);

The correct part of the community for development questions is here: monday Apps & Developers - monday Community Forum

This one is for users of apps and integrations.

That said! The issue is you’re using column titles like “Phone” instead of the column ID. (see the linked article below for finding column IDs). Secondly the phone value requires it be a number of the correct length and that you specify the two character country code:

"+5555551231234 US" or {phone: "+5555551231234", countShortName: "US"} (sorry for the JS syntax, not a PHP dev.

That said, good job going straight to using GraphQL variables! You’re saving yourself a lot of headache by doing that and also by not trying to build your columnVals as a string and actually using json_encode.

Thanks for the correction and the help. I have so many “Monday” tabs open it’s hard to keep them straight. :slight_smile:

Don’t worry, I see a ton of dev questions in the Platform discussions because the way its named sounds like its for dev in the first place, then having an apps & integrations subcategory makes it worse, then a “monday dev” category for the monday dev product makes it even worse!

Your help worked by the way. I am now able to populate the correct fields. Only one minor issue. The country flag doesn’t show up even though I am prefacing the number with “+1”. But I am grateful for your help as that one was a new one on me.

strange on the country flag, try using the {page: number, countryShortName: “US”} method?