Still having issues with column_values within create_item

I’ve scoured the forums for every suggestion on how to use the create_item manipulation and adding column values, but the column values never seem to update. I currently have a group that has a column called “Submission ID”. Here is my python code that is trying to create an item and populate it with a column value:

    headers = build_auth_header()
    column_data = {"Submission ID": "Test"}
    board = XXXXXXXXX
    group = 'topics'
    item_name = 'TEST'
    query = ("""
    mutation ($name: String!, $board: Int!, $group: String!, $columns: JSON!) {
        create_item (board_id: $board, group_id: $group, item_name: $name, column_values: $columns) {
            id
        }
    }
    """)
    graph_var = {
        "board": board,
        "group": group,
        "name": item_name,
        "columns": json.dumps(column_data)
    }
    response = requests.post('https://api.monday.com/v2/',
                             json={"query": query, "variables": graph_var},
                             headers=headers)

This posts as a success, but I do not see the value going into the column. Am I missing something?

Finally got it. I needed to use a function to get all of the column IDs for the board. In case anyone else wants to use it, here is the function I wrote:

def get_column_id_mapping(board_id, headers):
    boards = [int(board_id)]
    query = """
    query ($board: [Int]) {
      boards (ids: $board){
        columns{
          id
          title
          type
        }
      }
    }
    """
    graph_var = {"board": boards}
    result = run_graph_operation(query, headers, graph_var)
    mapping = {j['title']: j['id'] for j in result['data']['boards'][0]['columns']}
    return mapping
3 Likes