SuLab / WikidataIntegrator

A Wikidata Python module integrating the MediaWiki API and the Wikidata SPARQL endpoint
MIT License
244 stars 46 forks source link

Issue with writing to properties #63

Closed stuppie closed 6 years ago

stuppie commented 6 years ago
from wikidataintegrator import wdi_core, wdi_property_store, wdi_login
login = wdi_login.WDLogin("user", "pass")
wdi_property_store.wd_properties['P1628'] = {'core_id': True}
s = [wdi_core.WDUrl('http://schema.org/award', 'P1628')]
item = wdi_core.WDItemEngine(item_name="award received", domain="asf", data=s)
item.write(login, entity_type="property", property_datatype='wikibase-item')

WDApiError: {'error': {'messages': [{'html': {'': 'The requested feature is not supported by the given entity.'}, 'parameters': [], 'name': 'wikibase-api-not-supported'}], 'info': 'The requested feature is not supported by the given entity.', '': 'See https://www.wikidata.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&gt; for notice of API deprecations and breaking changes.', 'code': 'not-supported'}, 'servedby': 'mw1315'}

Not sure what is wrong, as it finds the item correctly:

In [10]: item.wd_item_id Out[10]: 'P166'

json representation of the statement being touched:

s = [x for x in item.statements if x.get_prop_nr() == 'P1628'][0]

{'id': 'P166$4f73b507-4c8d-eec3-210c-bcd83de7f736',
'mainsnak': {'datatype': 'url',
'datavalue': {'type': 'string', 'value': 'http://schema.org/award'},
'property': 'P1628',
'snaktype': 'value'},
'qualifiers': {},
'qualifiers-order': [],
'rank': 'normal',
'references': [],
'type': 'statement'}

and from the API (https://www.wikidata.org/w/api.php?action=wbgetentities&ids=P166&props=claims):

                    {
                        "mainsnak": {
                            "snaktype": "value",
                            "property": "P1628",
                            "hash": "31fe3af4f50d6fbc5813cdc4fb056cb7bceabb30",
                            "datavalue": {
                                "value": "http://schema.org/award",
                                "type": "string"
                            },
                            "datatype": "url"
                        },
                        "type": "statement",
                        "id": "P166$4f73b507-4c8d-eec3-210c-bcd83de7f736",
                        "rank": "normal"
                    }
stuppie commented 6 years ago

argh, it doesn't like the sitelinks