Python script, API call returning mirror columns 'text' and vaues as None

Hello community,

I am trying to get all items on differents boards into a csv, but I am having an issue, all conencted_boards mirror columns “text” and “values” coming from the API call are None. The Query and code goes as follows:

api_key = my_api_key
url = my_url

headers = {
'Authorization': api_key,
'API-Version' : '2024-01'
}

board_id = 'xxxxxxx'

#modifies depending on pagination.
query = f'''
    query {{
        boards(ids: {board_id}) {{
            items_count
            items_page(limit: 500{cursor_part}) {{
                cursor
                items {{
                    id
                    name
                    column_values {{
                        column {{
                            title
                        }}
                        type
                        text
                        value
                    }}
                }}
            }}
        }}
    }}

response = requests.post(url, headers=headers, json={'query': query})
data = response.json()

items = data['data']['boards'][0]['items_page']['items']

for item in items:
    item_values = {'Item ID': item['id'], 'Item Name': item['name']}
    for column_value in item['column_values']:
        print(column_value)

Finally when printing the information ALL the item_values coming from connected_boards/mirror have the following behavior:

{'column': {'title': 'Customer'}, 'type': 'mirror', 'text': None, 'value': None}
{'column': {'title': 'Opportunity'}, 'type': 'board_relation', 'text': None, 'value': '{"linkedPulseIds":[{"linkedPulseId":5361152121}]}'}

how to get my query or my code to retrieve thos empty values?

hi @juholaan1

For those columns that require access to different boards (like connect_boards and mirror columns) you need to ask for the value explicitly in a GraphQL fragment.

    query {{
        boards(ids: {board_id}) {{
            items_count
            items_page(limit: 500{cursor_part}) {{
                cursor
                items {{
                    id
                    name
                    column_values {{
                        column {{
                            title
                        }}
                        type
                        text
                        value
                        ... on BoardRelationValue {
                          display_value
                        }
                        ... on MirrorValue {
                          display_value
                        }
                    }}
                }}
            }}
        }}
    }}

Keep in mind you need to ack for display_value and not value.

2 Likes

Hello Bas de Bruin,

Thanks so much for your answer, that completely solves my issue here.

1 Like

Thank you @basdebruin for the help!!

1 Like