WikibaseIntegrator
WikibaseIntegrator copied to clipboard
Param-illegal error
I wanted to import P5192, which has the datatype wikibase-lexeme. This is the result of entity.get_json(): {'labels': {'en': {'language': 'en', 'value': 'Wikidata property example for lexemes'}, 'de': {'language': 'de', 'value': 'Wikidata-Eigenschaftsbeispiel für Lexeme'}}, 'descriptions': {'en': {'language': 'en', 'value': 'example where this Wikidata property is used; target lexeme is one that would use this property, with qualifier the property being described given the associated value'}}, 'aliases': {'en': [{'language': 'en', 'value': 'property example for lexemes'}]}, 'type': 'property', 'claims': {'P1': [{'mainsnak': {'snaktype': 'value', 'property': 'P1', 'datatype': 'external-id', 'datavalue': {'value': 'P5192', 'type': 'string'}}, 'type': 'statement', 'rank': 'normal', 'references': [{'snaks': {}, 'snaks-order': []}]}]}, 'datatype': 'wikibase-lexeme'}
However, I am getting the following error: {'error': {'code': 'param-illegal', 'info': 'A datatype was expected, but either missing or not recognized.', 'messages': [{'name': 'wikibase-api-not-recognized-datatype', 'parameters': [], 'html': {'': 'A datatype was expected, but either missing or not recognized.'}}], '': 'See http://wikibase.svc/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes.'}}
I am confused, why that would be, as wikibase-lexeme is a valid data type.
Hello @LizzAlice ,
Can you share your wikibase version?
Thanks
The mediawiki version is 1.38.1
The mediawiki version is 1.38.1
How did you install wikibase? Are you using wikibase suite that ensures compatible components?
Wikibase was installed in a docker as specified here: https://github.com/MaRDI4NFDI/docker-wikibase/blob/main/Dockerfile
Can you share the code that generate the error?
For getting the error message, I used this code taken from the wikibaseintegrator package, since otherwise, it dos not get displayed correctly.
try:
entity_description = entity.write(login=login)
except:
import ujson
data = entity.get_json()
payload = {
"action": "wbeditentity",
"data": ujson.dumps(data),
"format": "json",
"token": "+\\",
}
is_bot = self.wikibase_integrator.is_bot
if is_bot:
payload.update({"bot": ""})
payload.update({"new": entity.type})
login = self.wikibase_integrator.login
from wikibaseintegrator.wbi_config import config
mediawiki_api_url = config["MEDIAWIKI_API_URL"]
user_agent = "WikibaseIntegrator/0.12.0"
headers = {"User-Agent": user_agent}
payload.update({"token": login.get_edit_token()})
session = login.get_session()
response = None
import requests
from time import sleep
import json
for n in range(100):
try:
response = session.request(
method="POST",
url=mediawiki_api_url,
data=payload,
headers=headers,
)
except requests.exceptions.ConnectionError as e:
print(
"Connection error: %s. Sleeping for %d seconds.", e, 60
)
sleep(60)
continue
if response.status_code in (500, 502, 503, 504):
print(
"Service unavailable (HTTP Code %d). Sleeping for %d seconds.",
response.status_code,
60,
)
sleep(60)
continue
break
response.raise_for_status()
print(response.content)
What do you want to accomplish?
You want to import P1592 on your own wikibase, so with a new entity ID in the end?
Exactly, like mentioned in this issue https://github.com/LeMyst/WikibaseIntegrator/issues/456