Creating Item with column values

I’ve had success in creating new items on the board that I want from my Google apps script, but where I run into trouble is in the column_value part. Can’t quite seem to track down where I’m going wrong.

function myNewItem(){

var baseURL = “https://api.monday.com/v2
var mondayApiToken = “mondayToken”

var query = mutation newItem { create_item(board_id: 2942342848, group_id: "new_group85282", item_name: "test2", column_values: "{\"edit_request\" : \"New text\"}"){ id } }

var headers = {
“Authorization”: mondayApiToken,
“Content-Type”: “application/json”
}

var options = {

headers: headers,
method: "Post",
payload: JSON.stringify({

  query: query

})

}

var response = UrlFetchApp.fetch(baseURL, options).getContentText()
var result = JSON.parse(response)

console.log(“result:”, result.data)

}

Hi @Coda415,

Welcome to the community! We hope you like it here :rocket:

Could you please share the error you are seeing when trying to create an item?

{ errors: 

[ { message: ‘Parse error on " : " (STRING) at [5, 127]’,
locations: [Object] } ],
account_id: 11852553 }

Hello there @Coda415!

Could you please try this and let me know what happens?

var query = “mutation { create_item(board_id: 2942342848, group_id: "new_group85282", item_name: "test2", column_values: "{\"edit_request\" : \"New text\"}"){ id } }”

@Matias.Monday, thanks for the suggestion. I still got a parse error.

10:04:23 AM Info { errors:
[ { message: ‘Parse error on " : " (STRING) at [1, 121]’,
locations: [Object] } ],
account_id: 11852553 }

Also, for what it’s worth I can get it to work in the API playground. With this:

mutation{
createItem1: create_item(board_id: 2942342848, group_id: “new_group85282”, item_name: “test”, column_values:
“{"edit_request" : "test"}”) {
id
name
}
createItem2: create_item(board_id: 2942342848, group_id: “new_group85282”, item_name: “test2”, column_values: “{"edit_request" : "New text"}”) {
id

}
}

Hi @Coda415!

I’m sure it is just a silly thing we are missing here. But to avoid many back and forths, would you be able to schedule a meeting with us here so that we can take a look together?

We can probably solve it in a few minutes taking a look into the code together :slightly_smiling_face:

1 Like