Hi Florian and Amir,
Yes it's possible, see
https://commons.wikimedia.org/w/index.php?diff=945325248&oldid=945324579
. I'm currently using
https://doc.wikimedia.org/pywikibot/stable/api_ref/pywikibot.site.html#pywikibot.site._datasite.DataSite.editEntity
instead of
https://doc.wikimedia.org/pywikibot/stable/api_ref/pywikibot.page.html#pywikibot.WikibasePage.editEntity
because of https://phabricator.wikimedia.org/T376955 . See code as
https://github.com/multichill/toollabs/blob/master/bot/commons/geograph_describe.py
for example.
Labels is a dict, example what the API expects:
data['labels'] = {'en' : { 'language' : 'en',
'value' : 'some label',
}
}
editLabels is a wrapper around editEntity. editLabels({'en','some
label'}) works because the normalization function will change it into
the right API format, see
https://doc.wikimedia.org/pywikibot/stable/_modules/pywikibot/page/_collections.html#LanguageDict.normalizeData
.
Maarten
On 13-10-2024 23:30, Amir Sarabadani wrote:
Hi,
The error doesn't seem to be related to combining claims and labels or
the structure of payload for the edit. I think it's the error on how
you say what item needs to be edited. You can set either id (Q12345)
or both page and site (enwiki, Foo) but not both.
If you still have trouble, please drop the segment of the code
somewhere so I can take a look and help.
HTH
Am Sa., 12. Okt. 2024 um 19:48 Uhr schrieb tohuuu <t...@tohuuu.de>:
Hi all,
is there a way to set both SDC labels and SDC claims in one single
wbeditentity API call? I tried to pass a dictionary with the
following structure as data payload:
{'claims': [{...}, {...}, {...}], 'labels': {'de': 'german...',
'en': 'english ...'}}
but this triggerend an API error:
pywikibot.exceptions.APIError: not-recognized-array: An array was
expected, but not recognized.
Based on this error message, I assumed that the labels should get
passed as list, too:
{'labels': [{'language': 'de', 'value': 'de...'}, {'language':
'en', 'value': 'en...'}], 'claims': [{...}, {...}, {...}]}
but that gave me a different error:
pywikibot.exceptions.APIError: param-illegal: You need to provide
either an entity "id", or a "site" and "page" combination, but not
both.
Am I doing something wrong? Or is setting both SDC labels and SDC
claims not supported?
Thanks for any help!
Florian
_______________________________________________
pywikibot mailing list -- pywikibot@lists.wikimedia.org
Public archives at
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/MIPENXF2M34B3YSXVX25JARZHSLOAYVV/
To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
--
Amir (he/him)
_______________________________________________
pywikibot mailing list --pywikibot@lists.wikimedia.org
Public archives
athttps://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/TT4WXOAD5NIAHDH7PAZW33PCI5CNBHGP/
To unsubscribe send an email topywikibot-le...@lists.wikimedia.org
_______________________________________________
pywikibot mailing list -- pywikibot@lists.wikimedia.org
Public archives at
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/RN7SGMGPXPTYXOFW5A2P7KWIZKS722NW/
To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org