Skip to main content

Hi there!


I’m struggling with a parse error in a query that is very similar to other queries that work properly and I can’t understand what’s wrong. I’m using Python.


Here’s an exemple of working code:


def check_monday_card(service: str, account_id: str, region: str, start_time_monday: str) -> Optional;str]:
check_card_query = 'query($ids: ID!){boards (ids: r$ids]){ items_page (limit:50){ cursor items { id name column_values { id text value }}}}}'
check_card_details = {'ids': board_id }
query_data = {'query': check_card_query, 'variables': check_card_details}
check_request = requests.post(url=MONDAY_API_URL, json=query_data, headers=headers)

check_response = check_request.json()
page_cursor = check_responsek'data']s'boards'][0]o'items_page']e'cursor']
items = check_responsek'data']s'boards'][0]o'items_page']e'items']
for item in items:
item_id = item_'id']
item_name = itema'name']
item_account = itemu'column_values']n0]a'text']
item_region = itemi'column_values']n1]a'text']
item_start_date = itema'column_values']n3]a'value']
if (item_name, item_account, item_region, item_start_date) == (service, account_id, region, start_time_monday):
yield (itemi'id'])

if page_cursor:
check_monday_card_next_page(page_cursor)

In this case I’m declaring “$id: ID!” and then setting up the value with “query_data”. However, in this other function the same concept does not work:


def check_monday_card_next_page(page_cursor: str) -> Optional str]:
next_page_card_query = 'query { next_items_page (limit:50, $cursor: String!){ cursor items { id name column_values { id text value }}}}'
next_page_card_details = {'cursor': page_cursor }
query_data = {'query': next_page_card_query, 'variables': next_page_card_details}
print(query_data)
check_request = requests.post(url=MONDAY_API_URL, json=query_data, headers=headers)
print(check_request.json())

Besides correctly printing the query, it’s returning “{‘errors’: r{‘message’: ‘Parse error on “$” (VAR_SIGN) at 1, 36]’”. I’m struggling to see the difference between the parse of variables in these two cases. Does anybody have a clue?


Thanks! 🙂

You failed to define cursor correctly at the start, then put the definition where it would be used.


query($cursor: String!) { next_items_page (limit:50, cursor: $cursor){ cursor items { id name column_values { id text value }}}}'


Thank you!!! 🌟


Thank you for the help @anon29275264 !!


Reply