Reputation: 21
I'm trying to query Wikipedia API and retrieve the subcategories for a list of multiple categories, but it returns a 'bad title' error. I can't seem to find a solution in the documentation, anyone know if this is possible? Or do I need to run queries for one category at a time? Thanks!
"error": {
"code": "invalidtitle",
"info": "Bad title \"Category:Ice_hockey_by_country|Category:Ice_hockey_by_city\".",
"*": "See https://en.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
Note that this query for a single category seems to work: https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Ice_hockey_by_country&cmprop=title&cmtype=subcat&cmlimit=50
Upvotes: 2
Views: 558
Reputation: 1278
From what I read in the categorymembers
documentation, the cmtitle
parameter does not accept more than one category. It likely interpreted it as one category named Category:Ice_hockey_by_country|Category:Ice_hockey_by_city
instead of the two separate categories that you intended.
I guess you'll need to query the categories separately.
Upvotes: 0