Skip to main content

Can you pass board_id and item_id as variables in Python?

  • May 5, 2022
  • 3 replies
  • 1452 views

Eventually from running a query, I want to update a column with a next text value by referencing a board ID and item ID. I can pass variables into my mutation as a String!. I can’t figure out how or if I can pass numbers for the board ID and item ID. If tried Int!, Number!, etc. Is the possible? If so, what is the variable type? Code below shows me trying to pass the board ID through as a variable.

Code
vars4 = {
‘boardID’: ‘2383442606’,
‘itemID’ : ‘2632247819’,
‘columnID’ : ‘text90’,
‘updateTxt’ : ‘hello world’}

query4=‘mutation ($boardID: Int!, $updateTxt: String! ) {change_simple_column_value (board_id:$boardID, item_id:2632247819, column_id: “text90”, value:$updateTxt) {id}}’
data = {‘query’ : query4, ‘variables’: vars4}

r = requests.post(url=apiUrl, json=data, headers=headers) # make request
print(“Query 4”)
print(r.json())

Error
/Users/bruce/PycharmProjects/MondayCom/venv/bin/python “/Users/bruce/PycharmProjects/MondayCom/Weekly Update.py”
Query 4
{‘errors’: [{‘message’: ‘Variable boardID of type Int! was provided invalid value’, ‘locations’: [{‘line’: 1, ‘column’: 11}], ‘value’: ‘2383442606’, ‘problems’: [{‘path’: , ‘explanation’: ‘Could not coerce value “2383442606” to Int’}]}], ‘account_id’: 8981852}

Process finished with exit code 0

3 replies

basdebruin
  • Community Expert
  • May 5, 2022

Looks like your boardID is of type string while it need to be an Int


kolaai
Forum|alt.badge.img
  • monday.com Partner
  • May 5, 2022

So is the itemID 🙂 Both need to be Int


  • Author
  • New Participant
  • May 5, 2022

I wasn’t using ItemID yet. I first wanted to get boardID working. I removed the quotes around the boardID. Success! So the Int! does work. Thanks for the help.