Hello,
I’m having a problem trying to pass JSON value to columnValues field when creating an item using monday.api() method.
Attempt #1:
monday.api(`
mutation {
create_item (
board_id: 0000000,
group_id: "topics",
item_name: "Hello",
columnValues: "${JSON.stringify({people3: {personsAndTeams: [{id: 1111111, kind: 'person'}]}})}"
) {
id
}
}
`);
Here is the error response I got:
{
"errors": [
{
"message": "Parse error on \":{\" (STRING) at [7, 36]",
"locations": [
{
"line": 7,
"column": 36
}
]
}
],
"account_id": 2222222
}
Since the attempt #1 doesn’t work for me, I’ve tried the solution that I found in this community, but it still doesn’t work for me.
Attempt #2:
const body = {
query: `
mutation($boardId: Int!, $groupId: String!, $itemName: String!, $columnValues: JSON!) {
create_item (
board_id: $boardId,
group_id: $groupId,
item_name: $itemName,
columnValues: $columnValues
) {
id
}
}
`,
variables: {
boardId: 00000000,
groupId: 'topics',
itemName: data.item,
columnValues: JSON.stringify({people3: {personsAndTeams: [{id: 111111111, kind: 'person'}]}})
}
}
monday.api(JSON.stringify(body));
Here is the error response that I got:
{
"errors": [
{
"message": "Parse error on \"query\" (STRING) at [1, 2]",
"locations": [
{
"line": 1,
"column": 2
}
]
}
],
"account_id": 2222222
}
Any help is appreciated.
Thank you.