Thanks so much @dipro.
This works on GraphiQL but I am facing another issue when I moved the code to a Node JS project. Could you please help?
GrahiQL:
mutation {
create_item(
item_name: "TEST API 3",
board_id: ID,
group_id: "new_group",
column_values: "{\"people2\": null, \"text1\": \"Test Lead\", \"client4\": \"Test Client\", \"channel5\":\"Test channel\", \"status8\":null, \"text\": \"Test req by\", \"date\": { \"date\" : \"2019-01-20\" } }")
{
id
}
}
Node JS:
const body = {
query: `
mutation ($boardId: Int!, $groupId: String!, $itemName: String!, $columnValues: JSON!) {
create_item (
board_id: $boardId,
group_id: $groupId,
item_name: $itemName,
column_values: $columnValues
) {
id
}
}
`,
variables: {
boardId: ID,
groupId: "new_group",
itemName: "TEST - API New Request",
columnsValues: JSON.stringify({
people2: null,
text1: "Test Lead",
client4: "Test Client",
channel5: "Test channel",
status8: null,
text: "Test req by",
date: { date: "2019-01-20" }
})
}
};
axios
.post(`https://api.monday.com/v2`, body, {
headers: {
Authorization: "AUTH"
}
})
.catch(err => {
console.error("** error **", err.data);
})
.then(res => {
console.log("** success **", res.data);
});
Output:
** success ** {
errors: [
{
message: 'Variable columnValues of type JSON! was provided invalid value',
locations: [Array],
value: null,
problems: [Array]
}
],
account_id: ID
}