Getting empty values for an API request, where in playground will provide results

Hi,
I am trying to modify a python script that used a GraphQL query to retrieve data from monday via the API, that since the items-> item_pages transition stopped working.

I have used the playground and was able to generate updated query and get results per board and item, but when trying my script which does the same - just inside a loop the results come back empty.

This is what I have working in the playground:

And this is my code snippet that should do the same:

for item_id in item_ids:
# API query for item details
item_query = ‘’’
query {
boards(ids: %s) {
items_page(query_params:{ids: %s}) {
items {
id
name
column_values {
text
}
}
subitems {
name
column_values {
text
}
}
}
}
}
‘’’ % (board_id, item_id)

Please assist.
-Lavi

Hello there @Lavil,

You are closing the “items” object before asking for that item’s subitems.

Would you be able to please try this:

query {
boards(ids: %s) {
items_page(query_params:{ids: %s}) {
items {
id
name
column_values {
text
}
subitems {
name
column_values {
text
}
}
}
}
}
}

Thanks Matias, I corrected as you suggested and now get the subitems structure as part of the response. But this doesn’t solve my problem as the items still returns as “empty”.

This is an example of an empty item which I get now as the response:

query {
boards(ids: 6318008740) {
items_page(query_params:{ids: 6318008872}) {
items {
id
name
column_values {
text
}
}
subitems {
name
column_values {
text
}
}
}
}
}

Hello again,

That last query is still incorrect regarding the curly bracket. Here is the correct format:

{
  boards(ids: 1234567890) {
    items_page(query_params: {ids: 1122334455}) {
      items {
        id
        name
        column_values {
          text
        }
        subitems {
          name
          column_values {
            text
          }
        }
      }
    }
  }
}

If you do not get any items in the response at all, it means that the combination of that board ID and that item ID does not exist, or that the user whose API token you are using does not have access to it.

Please check that the item ID is the ID of an ITEM and not of a SUBITEM.

Please also check that the user whose API token is being used for the query has access to that item.

The query itself (the one I send here) is correct.

Just in case, for a query like this one, where you are querying for the data in one item only, you don’t need the “boards”, or “items_page” parts. You can use something like this:

{
  items(ids: 1122334455) {
    id
    name
    column_values {
      text
    }
    subitems {
      name
      column_values {
        text
      }
    }
  }
}

Let me know how that goes!

Cheers,
Matias

I think there’s something incorrect in how I write my POST request, so I read the page below:
https://www.postman.com/matiasdavidson/workspace/monday-com-queries-and-mutations/request/17637789-59506fc9-6570-4eb1-ac15-27869325a8cf

and using the code snippet that is mentioned there (for Python-requests), I was able to create the python script and get the results I wanted back.

My question is: how would you update the code snippet mentioned in the page, if I wanted to get results for only one item in the board?

Hello again @Lavil,

As I mentioned before, if you only need the data from one item, you can use something like this:

{
  items(ids: 1122334455) {
    id
    name
    column_values {
      text
    }
    subitems {
      name
      column_values {
        text
      }
    }
  }
}

If you still want to use items_page for only one item (which is not necessary), you could add the ID of the specific item in the query_params like this:

{
  boards(ids: 1234567890) {
    items_page(limit: 100, query_params: {ids: 1122334455}) {
      cursor
      items {
        id
        name
      }
    }
  }
}

Cheers,
Matias

Thanks a lot Matias! I managed to find the solution I needed with the information you provided,

I am glad that is the case @Lavil !!

Happy to help :grin: