Error populating the "rating" column in Monday.com

I’m trying to create a Monday.com item from a webhook. Everything works fine, except I’m not able to populate a “rating” column.

I receive an Error stating: “Failed to create item: invalid value…” But I don’t understand what data structure or syntax I should use.

Can anyone point me in the right direction?

Hi @thomas3,

To create a monday.com item with a “rating” column from a webhook, you need to ensure that the data structure and syntax match what monday.com expects for the “rating” column type. The “rating” column in monday.com is a bit unique because it expects a JSON object with specific properties.

Here’s an example of how you might structure your request to create an item with a “rating” column. This example assumes you’re using a Pipedream component to make the API call to monday.com:

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    monday: {
      type: "app",
      app: "monday",
    },
  },
  async run({ steps, $ }) {
    const query = `mutation ($boardId: Int!, $itemName: String!, $columnValues: JSON!) {
      create_item (board_id: $boardId, item_name: $itemName, column_values: $columnValues) {
        id
      }
    }`;

    const boardId = 123456789; // Replace with your actual board ID
    const itemName = "New Item"; // Replace with your desired item name
    // Replace 'rating_column_id' with your actual rating column's unique ID
    // and set the 'rating' value accordingly (value must be within the column's allowed range)
    const columnValues = JSON.stringify({
      rating_column_id: { rating: 5 },
    });

    return await axios($, {
      method: "post",
      url: `https://api.monday.com/v2`,
      headers: {
        "Authorization": `${this.monday.$auth.api_key}`,
        "Content-Type": "application/json",
      },
      data: {
        query,
        variables: {
          boardId,
          itemName,
          columnValues,
        },
      },
    });
  },
});

In this example, replace boardId with your actual board ID, itemName with the name you want for the new item, and rating_column_id with the unique ID of the rating column in your board. The rating value should be set according to the range allowed by your rating column (e.g., 1 to 5).

The key part here is the columnValues JSON object. For the “rating” column, you need to provide a JSON object with the rating key and

I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double-check my answers and code! Learn how to build your own.