Why I've got this errors and how can I fix them? #768
Unanswered
batukhantas
asked this question in
Q&A
Replies: 1 comment
-
Hello @batukhantas print(item.get_json()) Maybe we can understand what Wikibase didn't like in your JSON. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've got this error when I run this command, "PS C:\Users\TAS\wikibase-release-pipeline\deploy> python script.py
Login successful
Error while writing to the Wikibase instance
Traceback (most recent call last):
File "C:\Users\TAS\wikibase-release-pipeline\deploy.venv\lib\site-packages\wikibaseintegrator\entities\baseentity.py", line 243, in _write
json_result: dict = edit_entity(data=data, id=entity_id, type=self.type, summary=summary, clear=clear, is_bot=is_bot, allow_anonymous=allow_anonymous,
File "C:\Users\TAS\wikibase-release-pipeline\deploy.venv\lib\site-packages\wikibaseintegrator\wbi_helpers.py", line 333, in edit_entity
return mediawiki_api_call_helper(data=params, is_bot=is_bot, **kwargs)
File "C:\Users\TAS\wikibase-release-pipeline\deploy.venv\lib\site-packages\wikibaseintegrator\wbi_helpers.py", line 215, in mediawiki_api_call_helper
return mediawiki_api_call('POST', mediawiki_api_url=mediawiki_api_url, session=session, data=data, headers=headers, max_retries=max_retries, retry_after=retry_after, **kwargs)
File "C:\Users\TAS\wikibase-release-pipeline\deploy.venv\lib\site-packages\wikibaseintegrator\wbi_helpers.py", line 129, in mediawiki_api_call
raise MWApiError(json_data['error'])
wikibaseintegrator.wbi_exceptions.MWApiError: 'The save has failed.'
An error occurred: 'The save has failed.'"
Here is my script.py, `
""""
wbi = WikibaseIntegrator()
my_first_wikidata_item = wbi.item.get(entity_id='Q5')
to check successful installation and retrieval of the data, you can print the json representation of the item
print(my_first_wikidata_item.get_json())"""
from wikibaseintegrator import WikibaseIntegrator
from wikibaseintegrator.wbi_login import Clientlogin
from wikibaseintegrator.wbi_config import config as wbi_config
from wikibaseintegrator.wbi_enums import WikibaseDatatype
from wikibaseintegrator.models import Claim
from SPARQLWrapper import SPARQLWrapper, JSON
#from wikibaseintegrator.datatypes import URL, String
#wbi_config['MEDIAWIKI_API_URL'] = 'http://localhost:8880/w/api.php'
wbi_config['SPARQL_ENDPOINT_URL'] = 'http://localhost:8834/proxy/wdqs/bigdata/namespace/wdq/sparql'
wbi_config['WIKIBASE_URL'] = 'http://localhost:8880'
wbi_config['USER_AGENT'] = 'MyWikibaseBot/1.0'
#wbi_config['WIKIBASE_URL'] = 'http://wikibase.svc'
Initialize WikibaseIntegrator
try:
login_instance = Clientlogin(user='admin', password='admin12345')
wbi = WikibaseIntegrator(login=login_instance)
print("Login successful")
Example usage
Query existing data (this will print the SPARQL query to run in the query service)
except Exception as e:
print(f"Login failed. Error: {str(e)}")
print("Please check your username and password, and ensure your Wikibase instance is running.")
and login_test.py file,
from wikibaseintegrator import WikibaseIntegratorfrom wikibaseintegrator.wbi_config import config as wbi_config
from wikibaseintegrator.wbi_login import Clientlogin
Configuration
#wbi_config['MEDIAWIKI_API_URL'] = 'http://localhost:8880/w/api.php'
wbi_config['SPARQL_ENDPOINT_URL'] = 'http://localhost:8834/proxy/wdqs/bigdata/namespace/wdq/sparql'
wbi_config['WIKIBASE_URL'] = 'http://localhost:8880'
wbi_config['USER_AGENT'] = 'MyWikibaseBot/1.0'
#wbi_config['WIKIBASE_URL'] = 'http://wikibase.svc'
Attempt login
#username = "admin"
#password = "admin12345"
try:
login_instance = Clientlogin(user='admin', password='admin12345')
wbi = WikibaseIntegrator(login=login_instance)
print("Login successful!")
except Exception as e:
print(f"Login failed. Error: {str(e)}")
print("Please check your username and password, and ensure your Wikibase instance is running.")
and these lines which are lately added to LocalSettings.php due to chatgpt,
##############################################################################End of generated LocalSettings.php
##############################################################################
Add configuration values below which should be set after extensions are loaded
Grant all permissions to administrators
$wgGroupPermissions['sysop']['edit'] = true;
$wgGroupPermissions['sysop']['createpage'] = true;
$wgGroupPermissions['sysop']['createpagemainns'] = true;
$wgGroupPermissions['sysop']['delete'] = true;
$wgGroupPermissions['sysop']['undelete'] = true;
$wgGroupPermissions['sysop']['move'] = true;
$wgGroupPermissions['sysop']['patrol'] = true;
$wgGroupPermissions['sysop']['block'] = true;
$wgGroupPermissions['sysop']['upload'] = true;
$wgGroupPermissions['bot']['writeapi'] = true;
$wgEnableWriteAPI = true;
$wgDebugLogGroups['error'] = '/var/log/mediawiki/mw.error.log';`
Beta Was this translation helpful? Give feedback.
All reactions