I am trying to send Monday.com boards list and their items list to Google sheets with a column value. Here is my code:
function runMondayQuery() {
const apiKey = 'YOUR_MONDAY_API_KEY'; // Replace with your actual API key
const boardId = YOUR_BOARD_ID; // Replace with your actual board ID (number, not string)
const query = `
query {
boards(ids: [${boardId}]) {
id
name
items_page(limit: 100) {
items {
id
name
column_values {
id
title
text
value
}
}
cursor
}
}
}
`;
const options = {
method: 'post',
contentType: 'application/json',
headers: {
Authorization: apiKey,
'API-Version': '2023-10'
},
payload: JSON.stringify({ query })
};
const response = UrlFetchApp.fetch('https://api.monday.com/v2', options);
const data = JSON.parse(response.getContentText());
Logger.log(JSON.stringify(data, null, 2));
}
But I keep getting this error:
Response: {“errors”:[{“message”:“Cannot query field "items" on type "Board".”,“locations”:[{“line”:5,“column”:9}],“extensions”:{“code”:“GRAPHQL_VALIDATION_FAILED”}}]}