You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
traopia
changed the title
import entity from wikidata
import entity from wikidata errors: wikibaseintegrator.wbi_exceptions.MWApiError: 'The supplied language code was not recognized.'
Aug 7, 2024
For the first example, I am trying to import a wikidata entity into my wiki base and add a statement (based on my wiki base to it). It works for many entities, but for some it doesn't and give the error: "The supplied language code was not recognized."
CODE:
def copy_entity_wikibase_with_property(entity_id, property_id, value_id):
"""entity_id = wikidata entity id
property_id = wikibase property id
value_id = wikibase value id"""
failed_entities = []
try:
# Fetch the entity from Wikidata
entity = wbi.item.get(entity_id, mediawiki_api_url='https://www.wikidata.org/w/api.php', login=login_wikidata)
# Prepare the entity for writing to the new Wikibase instance
entity.claims = Claims() # Ensure claims are correctly processed if needed
statement = Item(value=value_id, prop_nr=property_id)
# Add the new statement to the entity
entity.claims.add(statement)
# Attempt to write the entity to the new Wikibase instance
entity.write(mediawiki_api_url='https://fashion.wikibase.cloud/w/api.php', login=login_testwikidata, as_new=True)
print(entity_id)
except Exception as e:
# Log the error and add the entity ID to the list of failed entities
failed_entities.append(entity_id)
pass
return failed_entities
EXAMPLE USAGE WHERE IT WORKS
copy_entity_wikibase_with_property('Q1891','P6','Q930')
EXAMPLE WHERE IT DOESNT WORK
copy_entity_wikibase_with_property('Q159','P6','Q930')
For the second error I think I found a fix: which is simply adding a space to the description imported - so that it doesn't match with the label.
I tried to reproduce your issue, without success.
I've a slightly more precise error message because the "ak" language doesn't exist on my Wikibase instance.
My issue is located, on the two entity, with the "ak" label, which doesn't exist anymore so you can't import it in new wikibase instance.
Which version of Mediawiki and Wikibase do you use?
Hi! I have this error for several entities that I am trying to import from wikidata:
wikibaseintegrator.wbi_exceptions.MWApiError: 'The supplied language code was not recognized.'
Or the following error:
wikibaseintegrator.wbi_exceptions.ModificationFailed: 'Label and and description for language code ta can not have the same value.'
How can I deal with this? They are quite a common errors (at least in my experience so far) so I guess there must be a way around.
Thank you!
The text was updated successfully, but these errors were encountered: