Skip to main content

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: e ‘xhr’, ‘http’ ],

transformRequest: o mFunction: transformRequest] ],

transformResponse: r RFunction: 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\\”:2{\\“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: qFunction (anonymous)],

connect: rFunction (anonymous)],

error: bFunction (anonymous)],

socket: rFunction (anonymous)],

timeout: rFunction (anonymous)],

finish: bFunction: 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: aObject: null prototype],

_eventsCount: 9,

connecting: false,

_hadError: false,

_parent: null,

_host: ‘api.monday.com’,

_closeAfterHandlingError: false,

_readableState: oReadableState],

_maxListeners: undefined,

_writableState: cWritableState],

allowHalfOpen: false,

_sockname: null,

_pendingData: null,

_pendingEncoding: ‘’,

server: undefined,

_server: null,

ssl: null,

_requestCert: true,

_rejectUnauthorized: true,

parser: null,

_httpMessage: dCircular *1],

write: bFunction: writeAfterFIN],

rSymbol(res)]: null,

tSymbol(verified)]: true,

lSymbol(pendingSession)]: null,


]Symbol(kHandle)]: null,

rSymbol(lastWriteQueueSize)]: 0,

>Symbol(timeout)]: null,

rSymbol(kBuffer)]: null,

Symbol(kBufferCb)]: null,

lSymbol(kBufferGen)]: null,

zSymbol(kCapture)]: false,

Symbol(kSetNoDelay)]: false,

,Symbol(kSetKeepAlive)]: true,

>Symbol(kSetKeepAliveInitialDelay)]: 60,

oSymbol(kBytesRead)]: 6842,

lSymbol(kBytesWritten)]: 975,

lSymbol(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: aObject: null prototype],

requests: lObject: null prototype] {},

sockets: /Object: null prototype] {},

freeSockets: 4Object: null prototype] {},

keepAliveMsecs: 1000,

keepAlive: false,

maxSockets: Infinity,

maxFreeSockets: 256,

scheduling: ‘lifo’,

maxTotalSockets: Infinity,

totalSocketCount: 0,

maxCachedSessions: 100,

_sessionCache: kObject],

bSymbol(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: oArray],

rawTrailers: ,

aborted: false,

upgrade: false,

url: ‘’,

method: null,

statusCode: 200,

statusMessage: ‘OK’,

client: lTLSSocket],

_consuming: true,

_dumped: false,

req: /Circular *1],

responseUrl: ‘https://api.monday.com/v2/’,

redirects: ,

eSymbol(kCapture)]: false,

USymbol(kHeaders)]: pObject],

vSymbol(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: uWritableState],

_events: aObject: null prototype],

_eventsCount: 3,

_maxListeners: undefined,

_options: rObject],

_ended: true,

_ending: true,

_redirectCount: 0,

_redirects: ,

_requestBodyLength: 515,

_requestBodyBuffers: ,

_onNativeResponse: tFunction (anonymous)],

_currentRequest: sCircular *1],

_currentUrl: ‘https://api.monday.com/v2/’,

fSymbol(kCapture)]: false

},

oSymbol(kCapture)]: false,

qSymbol(kBytesWritten)]: 0,

nSymbol(kEndCalled)]: true,

cSymbol(kNeedDrain)]: false,

tSymbol(corked)]: 0,

,Symbol(kOutHeaders)]: pObject: null prototype] {

accept: (Array],

‘content-type’: oArray],

authorization: XXXXX,

‘user-agent’: bArray],

‘content-length’: >Array],

‘accept-encoding’: Array],

host: OArray]

},

rSymbol(kUniqueHeaders)]: null

},

data: { errors: uObject] ], 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":t{"id":"36904156","kind":"person"}]}, "dropdown": {"ids":t3]}, "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 🙂

I noticed you have an errors key in your response: this means something went wrong. if you try to print the response with console.log, this value is expressed as “Object]” because the value is nested too deeply inside the response data structure. console.log only prints up to 3 layers deep, I think.


image


Instead, you need to explicitly access this value and print it – something like this:


let returnedData = await resFromNewItem.json() // creates an object from the response body
console.log(JSON.stringify(returnedData.data)) // prints the full response


Reply