Can't create item with column values using create_item() api endpoint

Hi guys,

I’m using javascript to create a new item and associated column values using Monday.com’s create_item graphQL endpoint. This is my code so far. When I run it only item with an item name shows up without any column value. Any feedback will be appreciated.

     const query =
        "mutation ($myBoardId: ID!, $myItemName: String!, $myColumnValues: JSON!) { create_item(board_id: $myBoardId, item_name: $myItemName, create_labels_if_missing: true, column_values: $myColumnValues) { id } }";

      const variables = {
        myBoardId: 5816701022,
        myItemName: "Yolo Swag",
        myColumnValues: JSON.stringify({
          Title: "CEO",
          Email: "dafuq@gmail.com",
        }),
      };

      await fetch("https://api.monday.com/v2", {
        method: "post",
        headers: {
          "Content-Type": "application/json",
          Authorization: env.MONDAY_DOT_COM_ACCESS_TOKEN,
        },
        body: JSON.stringify({
          query: query,
          variables: JSON.stringify(variables),
        }),
      })
        .then((res) => res.json())
        .then((res) => console.log(JSON.stringify(res, null, 2)));
    }),

hi @dearmannerism

Welcome to the community! Your stringified myColumnValues does not contain the columnId of that email column, something like

        myColumnValues: JSON.stringify({"email":{
          Title: "CEO",
          Email: "dafuq@gmail.com",
        }})

if the columnId is “email”

1 Like

If this is my column, how should I structure myColumnValues?

Information for finding the column Ids is this article.

2 Likes