help me to Create columns and items in a group from xl file, but gettig an error

here is my code to create from xl file `ts import * as XLSX from ‘xlsx’;

// Configuration
const API_TOKEN: string = process.env.API_TOKEN || ‘’;
const WORKSPACE_ID: number = 1634278;

// Headers for API requests
const headers = {
Authorization: API_TOKEN,
‘Content-Type’: ‘application/json’,
‘API-version’: ‘2023-10’,
};

interface ExcelColumns {
[key: string]: string;
}

interface ColumnMap {
[key: string]: string;
}

// Default column type
const DEFAULT_COLUMN_TYPE = ‘text’;

// Custom column type mappings (if needed)
const CUSTOM_COLUMN_TYPES: ExcelColumns = {
‘Task Name’: ‘text’, // Supported
Desc: ‘long_text’, // Supported
‘Due Date’: ‘date’, // Supported
Assignee: ‘people’, // Supported
Status: ‘status’, // Supported
};

// Status mapping (customize based on your workflow)
const STATUS_MAP: { [key: string]: { index: number; color: string } } = {
‘Not Started’: { index: 0, color: ‘#ff0000’ },
‘In Progress’: { index: 1, color: ‘#00ff00’ },
Done: { index: 2, color: ‘#0000ff’ },
};

async function main(): Promise {
try {
// 1. Read Excel file to get column headers
const workbook: XLSX.WorkBook = XLSX.readFile(‘tasks.xlsx’);
const sheetName: string = workbook.SheetNames[0];
const sheet: XLSX.WorkSheet = workbook.Sheets[sheetName];
const headersRow: string = XLSX.utils.sheet_to_json(sheet, {
header: 1,
})[0] as any;

    // 2. Map headers to column types
    const EXCEL_COLUMNS: ExcelColumns = {};
    headersRow.forEach((header: string) => {
        EXCEL_COLUMNS[header] =
            CUSTOM_COLUMN_TYPES[header] || DEFAULT_COLUMN_TYPE;
    });

    // 3. Create new board
    const createBoardQuery = `
        mutation {
            create_board(
                board_name: "Project Tasks",
                board_kind: public,
                workspace_id: ${WORKSPACE_ID}
            ) {
                id
            }
        }
    `;

    const boardResponse = await fetch('https://api.monday.com/v2', {
        method: 'POST',
        headers,
        body: JSON.stringify({ query: createBoardQuery }),
    });

    const boardData = await boardResponse.json();
    const boardId: string = boardData.data.create_board.id;
    console.log(`Created board ID: ${boardId}`);

    // 4. Create a group
    const createGroupQuery = `
        mutation {
            create_group(
                board_id: ${boardId},
                group_name: "Tasks Group"
            ) {
                id
            }
        }
    `;

    const groupResponse = await fetch('https://api.monday.com/v2', {
        method: 'POST',
        headers,
        body: JSON.stringify({ query: createGroupQuery }),
    });

    const groupData = await groupResponse.json();
    const groupId: string = groupData.data.create_group.id;
    console.log(`Created group ID: ${groupId}`);

    // 5. Create columns with descriptions
    for (const [title, type] of Object.entries(EXCEL_COLUMNS)) {
        const createColumnQuery = `
            mutation {
                create_column(
                    board_id: ${boardId},
                    title: "${title}",
                    description: "This is my ${title} column",
                    column_type: "${type}"
                ) {
                    id
                    title
                    description
                }
            }
        `;

        const columnResponse = await fetch('https://api.monday.com/v2', {
            method: 'POST',
            headers,
            body: JSON.stringify({ query: createColumnQuery }),
        });

        const columnData = await columnResponse.json();
        console.log(`Created column: `, columnData);
    }

    // 6. Read Excel data
    const data: any[] = XLSX.utils.sheet_to_json(sheet);

    // 7. Create items
    for (const row of data) {
        const columnValues: { [key: string]: any } = {};

        // Build column values
        Object.entries(EXCEL_COLUMNS).forEach(([colName, colType]) => {
            if (!row[colName]) return;

            switch (colType) {
                case 'date':
                    const isoDate: string = new Date(row[colName])
                        .toISOString()
                        .split('T')[0];
                    columnValues[colName] = JSON.stringify({
                        date: isoDate,
                    });
                    break;
                case 'people':
                    columnValues[colName] = JSON.stringify({
                        personsAndTeams: [
                            { id: row[colName], kind: 'person' },
                        ],
                    });
                    break;
                case 'status':
                    const status =
                        STATUS_MAP[row[colName]] ||
                        STATUS_MAP['Not Started'];
                    columnValues[colName] = JSON.stringify({
                        index: status.index,
                        post_id: null,
                        changed_at: new Date().toISOString(),
                    });
                    break;
                default:
                    columnValues[colName] = row[colName];
            }
        });

        // Create item
        const createItemQuery = `
            mutation {
                create_item(
                    board_id: ${boardId},
                    group_id: "${groupId}",
                    item_name: "${row['Task Name'] || 'Unnamed Task'}",
                    column_values: "${JSON.stringify(columnValues).replace(
                        /"/g,
                        '\\"'
                    )}"
                ) { id }
            }
        `;

        console.log(createItemQuery);

        const itemResponse = await fetch('https://api.monday.com/v2', {
            method: 'POST',
            headers,
            body: JSON.stringify({ query: createItemQuery }),
        });

        const itemData = await itemResponse.json();
        console.log(
            `Created task: ${row['Task Name'] || 'Unnamed Task'} (Status: ${
                row['Status']
            })`,
            itemData
        );
        await new Promise(resolve => setTimeout(resolve, 200)); // Rate limiting
    }

    console.log(
        '✅ Board, group, columns, and tasks created successfully!'
    );
    console.log(
        `Board URL: https://patilajit020s-team.monday.com/workspaces/1634278/boards/${boardId}`
    );
} catch (error: any) {
    console.error('🚨 Error:', error);
}

}

main();
`

Hi @09ajitpatil,

Welcome to the community!

Can you reply with more info about the error? At first glance, I notice that you’re calling a deprecated API version, so I wonder if your error is tied to that. We are only supporting versions 2024-10 and later.

Best,
Rachel