Skip to main content

Variable Mismatch on variable column_type

  • November 1, 2023
  • 8 replies
  • 505 views

  • Participating Frequently

Having some trouble trouble shooting my error. I’ve read through a few other solutions to what I believe the problem I am having, but have yet to find a solution. Is column_type not a String?

I am creating columns with the following code:

Note, I am using python=3.10

def create_columns(board_id, title, column_type, default_values=None):
    if default_values:
        vals_dict = {}
        for cnt, vals in enumerate(default_values):
            vals_dict[cnt + 1] = vals
        status_values = {"labels": vals_dict}
    else:
        status_values = ''

    query = """
    mutation ($boardId: ID!, $titleName: String!, $columnType: String!, $defaultValues: JSON) {
        create_column(
            board_id: $boardId
            title: $titleName
            column_type: $columnType
            defaults: $defaultValues
        ) {
            id
        }
        }
    """

    variables = {
    'boardId': board_id,
    'titleName': title,
    'columnType': column_type,
    'defualtValues': json.dumps(status_values, separators=(',', ':'))
    }

    datas = {
    'query': query,
    'variables': variables
    }

    r_boards = requests.post(url=apiUrl, headers=headers, data=json.dumps(datas)) # make request
    
    return r_boards

variables

>>>{'boardId': '123456', 'titleName': 'My - Title', 'columnType': 'status', 'defualtValues': '{"labels":{"1":"100 - column1","2":"200 - column2","3":"300 - column,,3"}}'}

Error Message

>>>{'errors': [{'message': 'Type mismatch on variable $columnType and argument column_type (String! / ColumnType!)', 'locations': [{'line': 6, 'column': 13}], 'path': ['mutation', 'create_column', 'column_type'], 'extensions': {'code': 'variableMismatch', 'variableName': 'columnType', 'typeName': 'String!', 'argumentName': 'column_type', 'errorMessage': 'Type mismatch'}}], 'account_id': 123456}

8 replies

  • Participating Frequently
  • November 2, 2023
monday API docs

lastly, I learned something about request.post is that it can take a json parameter instead of data and an object provided to json gets converted to json automatically - no needs to use json.dumps


  • Author
  • Participating Frequently
  • November 2, 2023

Thanks for pointing that out Cody. Glad it was so simple. I tried to match it against our last discussion and was confused why it wasn’t working. Thanks for pointing out the misspelling as well. I tried removing the json.dumps but failed with a Requests json Decode Error. Put it back in and it worked. Not if that is due to a pythonic issue/format.

Again, thanks for you help. Guess you will be helping me on all my monday.com api questions lol!


  • Participating Frequently
  • November 2, 2023

Okay you’re on my blacklist now! No help from me until someone else steps up! Kidding! Glad we got it sorted. But yeah, if you can figure out how to interpret the error messages, it goes a long way.


  • Author
  • Participating Frequently
  • November 2, 2023

I agree. The more time I spend working with it, the better I should get. Just need those few pointers here and there to initially learn.


  • Author
  • Participating Frequently
  • November 2, 2023

Hey Cody, I do have a follow up question. Not sure if I need to post a new question. I’ve noticed that if I have more than 5 defaultValues then the fifth index is used as a place holder within the board. However, if I have fewer than 5 defaultValues then an additional blank default value is automatically created to act as the place holder. Not sure if you have seen or ran into this before. I have not come across anything on monday’s create column documentation yet.


  • Author
  • Participating Frequently
  • November 2, 2023

I was able to use a work around and just skip the fifth index value, but that just seems a little silly to me.


  • Participating Frequently
  • November 2, 2023

index 5 is the gray default, oddly not 0 or 1. You can’t change it.


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • November 5, 2023

Thank you @anon29275264 for the help here!