Skip to main content

Creating an item & then populating it with data

  • February 11, 2020
  • 1 reply
  • 1437 views

Hi all,

I’m trying to create items on my own board using garphql, axios and nodejs.

for some reason when i try to send the columnValues i get the followong errMessage:

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

and here is what i’m doing 🙂

 const createItem = {
          query: `
          mutation ($boardId: Int!, $groupId: String!, $itemName: String!) {
            create_item (
              board_id: $boardId,
              group_id: $groupId,
              item_name: $itemName,
            ) {
              id
              }
            }`,
            
            variables: {
              boardId: +BOARD,
              groupId: "topics",
              itemName: `${title}`,
              }
            }

            axios.post(`${URL}`, createItem, {
                headers: {
                  Authorization: `${KEY}`
                }
              }).then(res => {
                console.log(res.data.data.create_item.id)
                let itemId = res.data.data.create_item.id;

              const fillItem = {
                query: `
                mutation ($boardId: Int!, $itemId: Int!, $columnValues: JSON!) {
                  change_multiple_column_values (
                    board_id: $boardId,
                    item_id: $itemId,
                    column_values: $columnValues
                  ) {
                    id
                  }
                }`,

                variables: {
                  boardId: +BOARD,
                  itemId: +itemId,
                  groupId: "topics", 
                  columnValues: JSON.stringify({
                    text8: problem_type,
                    text9: problem_sub_type,
                    text7: third_level_category,
                    text5: description, 
                    text4: assigned_group,
                    text1: responsability,
                    text6: request_user,
                    text61: submit_user,
                    text97: request_user_email,
                    text3: request_user_cellphone,
                    text33: module_klh,
                    text50: df_phone_number,
                 
                  })
                }
              }
              axios.post(`${URL}`, fillItem, {
                headers: {
                  Authorization: `${KEY}`
                }
              }).then(res => console.log(res.data.errors[0]))
              .catch(err => console.log(err.data))
This topic has been closed for replies.

1 reply

dipro
Forum|alt.badge.img
  • Leader
  • February 14, 2020

Can you please add the code example that contains the column values? Doesn’t look like that is included in your code right now.

Looking forward to the additional context.