Parse Error with Create Item api

I keep getting errors when I try and create items using the monday-js-sdk. I should have everything formatted correctly.

const error = await monday.api(`
          mutation {
            create_item(board_id: 4260005974, group_id: ${groupId}, item_name: ${user.name}) {
              id
            }
          }
        `);

The error I get back is a parsing error on the graphql query:

{
    "errors": [
        {
            "message": "Parse error on \")\" (RPAREN) at [3, 92]",
            "locations": [
                {
                    "line": 3,
                    "column": 92
                }
            ]
        }
    ],
    "account_id": 8165721
}

Any ideas on how to fix or why this isn’t working?

The solution is to add quotations around the data for: group_id and item_name as follows:

const error = await monday.api(`
          mutation {
            create_item(board_id: 4260005974, group_id: "${groupId}", item_name: "${user.name}") {
              id
            }
          }
        `);
1 Like