Mutation create_item - how to format date column?

Hi, I am trying to create a new item and set the columns values from the beginning to avoid changing the values in a separate API call.

mutation {
  create_item(
    item_name: "Name",
    board_id: ID,
    group_id: "GROUP",
    
      column_values: "{\"date\": \"2019-01-20\" }" )
  {
    id
  }
}

This gives me this error:

  "error_code": "ColumnValueException",
  "status_code": 400,
  "error_message": "change_column_value invalid value",
  "error_data": {
    "column_value": "2019-01-20",
    "column_type": "DateColumn"

Any suggestions?

Hey Ahmed! The data for the date column should be in the format {"date" : "2019-01-20", "time" : "00:00:00"}. Try sending this instead:

"{ \"date\" : { \"date\" : \"2019-01-20\" } }

The first “date” is the column ID of the date column, and the second “date” tells the column to assign the cell with the date value of Jan 20. Let me know if that does the trick.

Thanks so much @dipro-monday.com.

This works on GraphiQL but I am facing another issue when I moved the code to a Node JS project. Could you please help?

GrahiQL:

mutation {
  create_item(
    item_name: "TEST API 3", 
    board_id: ID, 
    group_id: "new_group", 
    column_values: "{\"people2\": null, \"text1\": \"Test Lead\", \"client4\": \"Test Client\", \"channel5\":\"Test channel\", \"status8\":null, \"text\": \"Test req by\", \"date\": { \"date\" : \"2019-01-20\" } }")
   {
    id
  }
}

Node JS:

const body = {
			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: ID,
				groupId: "new_group",
				itemName: "TEST - API New Request",
				columnsValues: JSON.stringify({
					people2: null,
					text1: "Test Lead",
					client4: "Test Client",
					channel5: "Test channel",
					status8: null,
					text: "Test req by",
					date: { date: "2019-01-20" }
				})
			}
		};

		axios
			.post(`https://api.monday.com/v2`, body, {
				headers: {
					Authorization: "AUTH"
				}
			})
			.catch(err => {
				console.error("** error **", err.data);
			})
			.then(res => {
				console.log("** success **", res.data);
			});

Output:

** success ** {
  errors: [
    {
      message: 'Variable columnValues of type JSON! was provided invalid value',
      locations: [Array],
      value: null,
      problems: [Array]
    }
  ],
  account_id: ID
}

Hi @dipro-monday.com, have you got a chance to see my above issue? I am unable to understand what is wrong. Please help me.

Try this instead for your column_values
The columns you are trying to make null are expecting a json object type but being given null. To make the field null you need to give a json object with a null key pair i.e. {null:null}

Thanks @Alex.M. Unfortunately it shows this error:

{

* errors: [
  * {
    * message: "Variable columnValues of type JSON! was provided invalid value",

    * locations: [
      * {
        * line: 2,

        * column: 69}],

    * value: null,

    * problems: [
      * {
        * path: [ ],

        * explanation: "Expected value to not be null"}]}],

* account_id: 1580874

}

For this query:

{
			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: 393850461,
				groupId: "new_group",
				itemName: "TEST - API New Request",
				columnsValues: JSON.stringify({ people2: { null: null }, text1: "Test Lead", client4: "Test Client", channel5: "Test channel", status8: { null: null }, text: "Test req by", date: { date: "2019-01-20" } })
			}
		};

Hey Ahmed,

Instead of sending {null:null} for the value of people2, just omit it. If you don’t include a column in the values you send it will be set as empty :slight_smile:

Let me know if that helps!