Hi, I’m trying to create a pulse via Node.JS with axios. I started with the example that is on this forum and edited it for my needs but I can’t get my code to add the column values for the pulse. What am I doing wrong?
// Packages
const axios = require("axios"),
fs = require("fs");
// Files
const config = require("../config.json")
// Code
const body = {
title: "Test bug",
culprit: "util/testers/monday.js"
}
const current = new Date()
let month = current.getMonth() + 1
if (month < 10) {
month = `0${current.getMonth() + 1}`
}
const axiosBody = {
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: BOARDID,
groupId: "topics",
itemName: `${body.title} from ${body.culprit}`,
columnsValues: JSON.stringify({ status9: { index: 6 }, status: { index: 6 }, due_date: { date: `${current.getFullYear()}-${month}-${current.getDate()}` } })
}
}
axios.post(`https://api.monday.com/v2`, axiosBody, {
headers: {
Authorization: config.prod.monday.apitoken
}
})
.catch(err => {
console.error(err.data)
//fs.writeFileSync("./mondayerror.txt", JSON.stringify(err.data))
})
.then(res => {
console.log(res.data)
fs.writeFileSync("./mondayerror.txt", JSON.stringify(res.data, null, 4))
})