Trouble creating new item and populating multiple columns

I am trying to pull email from GMail (Business) and create an item on a board with the contents of each message. To begin on this I’m just trying to create a new item on a board with test data in multiple columns. I found a previous message (now closed) that started to address this but the ending solution was not posted to the thread: Creating an item with columns populated

What I have now is the following:
mutation {
create_item (
board_id: ,
group_id: “Incoming”,
item_name: “NEW API created item”,
column_values:
“{
"Description":"Hello world",
"email" :{"email":"test@test.com","text":"test@test.com"}
}”
) {
id
}
}

It completes and creates an item, but the Description column is not populated. The previous message indicates that one has to use the numeric ID of the column instead of the “friendly” name, but I don’t know how to get it.

What is the syntax for creating a new item and populating multiple fields, and how does one get the numeric ID for a column?

Thanks,

1 Like

Hey Scott, welcome :wave:

Good question! You’re right, you’ll need to use the column ID to assign “hello world” to the description column. Other than that, your syntax looks great so far.

We’re working on a way to make getting the column IDs easier, but for now I’d suggest using this query to get the title and ID of each column on a given board:

query {
  boards(ids:xxxxx) {
    columns {
      id
      title
    }
  }
}

Let me know if that helps!

Thanks for the help. I issued the query with the following results:
{
“data”: {
“boards”: [
{
“columns”: [
{
“id”: “name”,
“title”: “Name”
},
{
“id”: “person”,
“title”: “Owner”
},
{
“id”: “long_text”,
“title”: “Description”
},
{
“id”: “email”,
“title”: “Email”
},
{
“id”: “status”,
“title”: “Status”
},
{
“id”: “date”,
“title”: “Due”
},
{
“id”: “check”,
“title”: “Emergency”
}
]
}
]
},
“account_id”:
}

From this, I changed my call to (this is not exact because your editor is removing slashes and making formatting changes):

mutation {
create_item (
board_id: ,
group_id: “Incoming”,
item_name: “Test item:created via API”,
column_values:
“{
"long_text":"Hello world",
"email" :{"email":"test@test.com","text":"test@test.com"}
}”
) {
id
}
}

But it returned an error:
{
“error_code”: “ColumnValueException”,
“status_code”: 400,
“error_message”: “change_column_value invalid value”,
“error_data”: {
“column_value”: “Hello world”,
“column_type”: “LongTextColumn”
}
}

I checked the syntax for long text columns (https://monday.com/developers/v2#column-values-section-longtext), and mine seems to be correct. We’re closer, but not quite there yet. Can you offer any more guidance?

Thanks,

Hey Scott!

Almost there – the text column and long text column have slightly different data structures.

If you were updating a text column, you’d send something like this (myColumn is the column ID of my imaginary column):

column_values: {
  "myColumn" : "\"Hello world\""
}

However, for the long text column, you need to send a JSON object with “text” as the key. Something like this:

column_values: {
  "myColumn" : "{\"text\" : \"Hello world\"}"
}

Let me know if that does the trick.

We’re close. I have working code, but I have a question about it:

mutation {
create_item (

board_id: 262175425,
group_id: "Incoming",
item_name: "Test item:created via API",
column_values:
"{

“long_text” :{“text” :“This is where the message body was in the email. What happens to paragraphs?”},
“email” :{“email”:“What is this part?,“text”:"sender@invitae.com"}
}"
) {
id
}
}

1 Like