Error while updating board-relation value

Hi,

I’m trying to update the board-relation value in an item.
The column id I want to update is: ‘boards_verbinden9’, and it’s type is: ‘board-relation’.

The item_id = ‘1281247162’
the contact_id (item_id from the item in the other board I want to connect it to) = ‘1281240291’

The query I’m using in Python is:

query = ' mutation ($myItemID: ID!, $columnVals: JSON!) { change_multiple_column_values (item_id: $myItemID, board_id: 1274270217, column_values:$columnVals) { id } }'
vars = {'$myItemID': item_id,
        'columnVals': json.dumps({
            "boards_verbinden9": f'{{"linkedPulseIds":[{{"linkedPulseId":{contact_id} }}]}}'
        })}
data = {'query': query, 'variables': vars}
monday_headers = {"Authorization": API-KEY, 'API-Version': '2023-10'}
monday_apiUrl = "https://api.monday.com/v2"
r = requests.post(url=monday_apiUrl, json=data, headers=monday_headers)
r = r.json()

And the error I’m obtaining is:

{'errors': [{'message': 'Variable $myItemID of type ID! was provided invalid value', 'locations': [{'line': 1, 'column': 12}], 'extensions': {'value': None, 'problems': [{'path': [], 'explanation': 'Expected value to not be null'}]}}], 'account_id':XXXXX}

$myItemID var is of type ID since I’m using ‘API-Version’: ‘2023-10’

Please help me identifying what I’m doing wrong.

Thanks!

1 Like

I believe you should use myItemID and not $myItemId as the key in your vars object.

The variable in the query is named $myItemID which is going to look for a key in vars named myItemID. In this case it doesn’t exist so its null.

vars = {'myItemID': item_id,
        'columnVals': json.dumps({
            "boards_verbinden9": f'{{"linkedPulseIds":[{{"linkedPulseId":{contact_id} }}]}}'
        })}

Thanks Cody, you are right.

The corrected call is:

query = ' mutation ($myItemID: ID!, $columnVals: JSON!) { change_multiple_column_values (item_id: $myItemID, board_id: 1274270217, column_values:$columnVals) { id } }'
vars = {'myItemID': item_id,
        'columnVals': json.dumps({
            "connect_boards": {'item_ids': [contact_id]}}
        )}
data = {'query': query, 'variables': vars}
monday_headers = {"Authorization": API-KEY, 'API-Version': '2023-10'}
monday_apiUrl = "https://api.monday.com/v2"
r = requests.post(url=monday_apiUrl, json=data, headers=monday_headers)
r = r.json()

Nevertheless, I receive the error as if the boards where not connected.

{'error_code': 'ColumnValueException', 'status_code': 200, 'error_message': 'There are items that are not in the connected boards', 'error_data': {}}

In my board (the board of the item_id) I already have a “board-relation” column that connects with the other board (the board of the contact_id). In this column I already have some items related to the other board. Do you perhaps know what could be happening?

I found the error, the client_id in this case should be an Int and not a String.

See also: Connect boards and in particular: