I’ve been using the following to create an item on a board:
export const createItem = async (variables: any, shortLivedToken: string) => {
const monday = mondaySdk();
monday.setToken(shortLivedToken);
const query = `
mutation createItem (
$board_id: ID!
$group_id: String!
$item_name: String!
$column_values: JSON!
){
create_item (
board_id: $board_id,
group_id: $group_id,
item_name: $item_name,
column_values: $column_values
) {
id
}
}
`;
const options = { variables };
const response = await monday.api(query, options);
return response;
};
When passing this data in:
const variables = {
board_id: 7833822272,
group_id: "topics",
item_name: "Project Pivot",
column_values: JSON.stringify({
status: "14", // aka `Approved`
date4: "2024-07-29 11:00:00",
long_text: "Pivot demo",
numbers3: 40
})
};
const item = await createItem(variables, shortLivedToken);
console.log(`Created item? "${itemName}":`, item );
console.log(`variables:`, variables );
It gives me the following errors from the console.log
lines:
Created item? "Project Pivot": {
"errors": :
{
"message": "Unauthorized field or type",
"path": :
"create_item"
],
"extensions": {
"code": "UNAUTHORIZED_FIELD_OR_TYPE"
}
}
],
"account_id": 11749326
}
variables: {
"board_id": 7833822272,
"group_id": "topics",
"item_name": "Project Pivot",
"column_values": "{\\"status\\":\\"14\\",\\"date4\\":\\"2024-07-29 11:00:00\\",\\"long_text\\":\\"Pivot demo\\",\\"numbers3\\":40}"
}
I think that this suggests there’s something odd about one of the fields UNAUTHORIZED_FIELD_OR_TYPE
.
But when I look at the columns, using:
{
boards(ids: d7833822272]) {
columns {
id
type
settings_str
}
}
}
I get the following:
{
"data": {
"boards": s
{
"columns": s
{
"id": "name",
"type": "name",
"settings_str": "{}"
},
{
"id": "person",
"type": "people",
"settings_str": "{}"
},
{
"id": "status",
"type": "status",
"settings_str": "{\\"done_colors\\":\1],\\"hide_footer\\":true,\\"color_mapping\\":{\\"1\\":14,\\"14\\":1},\\"labels\\":{\\"0\\":\\"Under consideration\\",\\"2\\":\\"Rejected\\",\\"7\\":\\"New request\\",\\"14\\":\\"Approved\\"},\\"labels_positions_v2\\":{\\"0\\":1,\\"2\\":3,\\"5\\":4,\\"7\\":0,\\"14\\":2},\\"labels_colors\\":{\\"0\\":{\\"color\\":\\"#fdab3d\\",\\"border\\":\\"#e99729\\",\\"var_name\\":\\"orange\\"},\\"2\\":{\\"color\\":\\"#df2f4a\\",\\"border\\":\\"#ce3048\\",\\"var_name\\":\\"red-shadow\\"},\\"7\\":{\\"color\\":\\"#579bfc\\",\\"border\\":\\"#4387e8\\",\\"var_name\\":\\"bright-blue\\"},\\"14\\":{\\"color\\":\\"#00c875\\",\\"border\\":\\"#00b461\\",\\"var_name\\":\\"green-shadow\\"}}}"
},
{
"id": "date4",
"type": "date",
"settings_str": "{}"
},
{
"id": "long_text",
"type": "long_text",
"settings_str": "{}"
},
{
"id": "long_text9",
"type": "long_text",
"settings_str": "{}"
},
{
"id": "anticipated_outcomes",
"type": "long_text",
"settings_str": "{}"
},
{
"id": "numbers3",
"type": "numbers",
"settings_str": "{\\"unit\\":{\\"symbol\\":\\"$\\",\\"custom_unit\\":\\"\\",\\"direction\\":\\"left\\"}}"
},
{
"id": "button__1",
"type": "button",
"settings_str": "{}"
}
]
}
]
},
"account_id": ...
}
All column types and values look perfectly reasonable.
What could be the reason for the UNAUTHORIZED_FIELD_OR_TYPE
error message?