Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Param-illegal error #455

Open
LizzAlice opened this issue Nov 28, 2022 · 8 comments
Open

Param-illegal error #455

LizzAlice opened this issue Nov 28, 2022 · 8 comments
Assignees

Comments

@LizzAlice
Copy link

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.

@LeMyst
Copy link
Owner

LeMyst commented Nov 28, 2022

Hello @LizzAlice ,

Can you share your wikibase version?

Thanks

@LizzAlice
Copy link
Author

The mediawiki version is 1.38.1

@dpriskorn
Copy link
Contributor

dpriskorn commented Nov 28, 2022

The mediawiki version is 1.38.1

How did you install wikibase? Are you using wikibase suite that ensures compatible components?

@LizzAlice
Copy link
Author

Wikibase was installed in a docker as specified here: https://github.com/MaRDI4NFDI/docker-wikibase/blob/main/Dockerfile

@LeMyst
Copy link
Owner

LeMyst commented Nov 28, 2022

Can you share the code that generate the error?

@LizzAlice
Copy link
Author

LizzAlice commented Nov 28, 2022

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) 

@LeMyst
Copy link
Owner

LeMyst commented Nov 28, 2022

What do you want to accomplish?

You want to import P1592 on your own wikibase, so with a new entity ID in the end?

@LizzAlice
Copy link
Author

Exactly, like mentioned in this issue #456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants