Hi :_),
I have a working mutation (tested on playground, does the job) to insert a new item with populated columns:
mutation { create_item( board_id: ${MondayService.issuesBoardId}, group_id: ${MondayService.clientTicketGroupId}, item_name: "fromApp12", column_values: "{\"people2\":{\"personsAndTeams\":[{\"id\":\"36904156\",\"kind\":\"person\"}]}, \"dropdown\": {\"ids\":[3]}, \"status94\": {\"index\": 2, \"post_id\":null}, \"status3\": {\"index\": 2, \"post_id\":null}, \"dup__of_severity\": {\"index\": 2, \"post_id\":null} }") { id name } }
I am attempting to use it in the following way:
console.log(resFromNewItem);
if (resFromNewItem.status === 200) {
console.log("New Item created Succesfully!");
} else {
console.log("Error creating item: ", resFromNewItem.data);
}
} catch (err) {
console.log("error in monday fetchAllBoardIssues: ", err);
res.status(400).json(err);
}
where ‘query’ is the returned mutation given above.
I get the following response:
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [ ‘xhr’, ‘http’ ],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: ‘XSRF-TOKEN’,
xsrfHeaderName: ‘X-XSRF-TOKEN’,
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function], Blob: [class Blob] },
validateStatus: [Function: validateStatus],
headers: AxiosHeaders {
Accept: ‘application/json, text/plain, /’,
‘Content-Type’: ‘application/json’,
Authorization: XXXXXXX,
‘User-Agent’: ‘axios/1.2.3’,
‘Content-Length’: ‘515’,
‘Accept-Encoding’: ‘gzip, compress, deflate, br’
},
method: ‘post’,
url: ‘https://api.monday.com/v2/’,
data: ‘“mutation {\n create_item(\n board_id: 3782143770,\n group_id: new_group70712,\n item_name: \“fromApp12\”,\n column_values: \”{\“people2\”:{\“personsAndTeams\”:[{\“id\”:\“36904156\”,\“kind\”:\“person\”}]}, \“dropdown\”: {\“ids\”:[3]}, \“status94\”: {\“index\”: 2, \“post_id\”:null}, \“status3\”: {\“index\”: 2, \“post_id\”:null}, \“dup__of_severity\”: {\“index\”: 2, \“post_id\”:null} }\") {\n id\n name\n }\n} "’
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
finish: [Function: requestOnFinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: ,
outputSize: 0,
writable: true,
destroyed: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: ‘515’,
_hasBody: true,
_trailer: ‘’,
finished: true,
_headerSent: true,
_closed: true,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: false,
_SNICallback: null,
servername: ‘api.monday.com’,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 9,
connecting: false,
_hadError: false,
_parent: null,
_host: ‘api.monday.com’,
_closeAfterHandlingError: false,
_readableState: [ReadableState],
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: ‘’,
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular *1],
write: [Function: writeAfterFIN],
[Symbol(res)]: null,
[Symbol(verified)]: true,
[Symbol(pendingSession)]: null,
[Symbol(async_id_symbol)]: 515,
[Symbol(kHandle)]: null,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kSetNoDelay)]: false,
[Symbol(kSetKeepAlive)]: true,
[Symbol(kSetKeepAliveInitialDelay)]: 60,
[Symbol(kBytesRead)]: 6842,
[Symbol(kBytesWritten)]: 975,
[Symbol(connect-options)]: [Object]
},
_header: ‘POST /v2/ HTTP/1.1\r\n’ +
‘Accept: application/json, text/plain, /\r\n’ +
‘Content-Type: application/json\r\n’ +
'Authorization: XXXXXXXX +
‘User-Agent: axios/1.2.3\r\n’ +
‘Content-Length: 515\r\n’ +
‘Accept-Encoding: gzip, compress, deflate, br\r\n’ +
‘Host: api.monday.com\r\n’ +
‘Connection: close\r\n’ +
‘\r\n’,
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: ‘https:’,
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype] {},
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: ‘lifo’,
maxTotalSockets: Infinity,
totalSocketCount: 0,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: ‘POST’,
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: ‘/v2/’,
_ended: true,
res: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
socket: [TLSSocket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: ‘1.1’,
complete: true,
rawHeaders: [Array],
rawTrailers: ,
aborted: false,
upgrade: false,
url: ‘’,
method: null,
statusCode: 200,
statusMessage: ‘OK’,
client: [TLSSocket],
_consuming: true,
_dumped: false,
req: [Circular *1],
responseUrl: ‘https://api.monday.com/v2/’,
redirects: ,
[Symbol(kCapture)]: false,
[Symbol(kHeaders)]: [Object],
[Symbol(kHeadersCount)]: 42,
[Symbol(kTrailers)]: null,
[Symbol(kTrailersCount)]: 0
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: ‘api.monday.com’,
protocol: ‘https:’,
_redirectable: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: ,
_requestBodyLength: 515,
_requestBodyBuffers: ,
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular *1],
_currentUrl: ‘https://api.monday.com/v2/’,
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kEndCalled)]: true,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
‘content-type’: [Array],
authorization: XXXXX,
‘user-agent’: [Array],
‘content-length’: [Array],
‘accept-encoding’: [Array],
host: [Array]
},
[Symbol(kUniqueHeaders)]: null
},
data: { errors: [ [Object] ], account_id: 2679704 }
}
New Item created Succesfully!
And no item is being inserted.
Any ideas?
Edit: tried also in the following way:
const resFromNewItem = await axios.post(
mondayEndpoint,
{ query: query },
{ headers }
);
then I get:
New Item created Succesfully!
error in monday fetchAllBoardIssues: TypeError: Converting circular structure to JSON
→ starting at object with constructor ‘ClientRequest’
| property ‘socket’ → object with constructor ‘TLSSocket’
— property ‘_httpMessage’ closes the circle
at JSON.stringify ()
at stringify (/Users/dani_l_n/Documents/jan15/juno-issues-reporter/backend/node_modules/express/lib/response.js:1150:12)
at ServerResponse.json (/Users/dani_l_n/Documents/jan15/juno-issues-reporter/backend/node_modules/express/lib/response.js:271:14)
at /Users/dani_l_n/Documents/jan15/juno-issues-reporter/backend/controllers/mondayController.ts:146:23
at Generator.next ()
edit#2: Tried also the following:
const query: string =
'mutation {create_item(board_id: 3782143770, group_id: new_group70712, item_name: "fromApp", column_values: "{"people2":{"personsAndTeams":[{"id":"36904156","kind":"person"}]}, "dropdown": {"ids":[3]}, "status94": {"index": 2, "post_id":null}, "status3": {"index": 2, "post_id":null}, "dup__of_severity": {"index": 2, "post_id":null} }") {idname}}';
fetch("https://api.monday.com/v2", {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: MondayService.apiKey,
},
body: JSON.stringify({
query: query,
}),
}).then((data) => {
console.log("dataresp; ", data);
return data;
});
Regards