Description:
Assume I have item variable in Pywikibot being an instance of ItemPage (Wikidata item) or MediaInfo (Commons structured data). I add labels/claims to it via item.claims.setdefault('P123', []).append(claim) (in order not to make hundreds of edits) and then run:
item.editEntity(summary='my edit')
This works perfectly for ItemPage. Though, it doesn't work for MediaInfo -- labels get added, but not claims.
The reason I believe is that when data is serialized to JSON in WikibaseEntity.editEntity(), Commons API needs it to have the "claims" field -- not "statements" like Wikidata.
I currently use the following workaround for SDC:
data = item.toJSON(diffto=getattr(item, '_content', None)) data['claims'] = data['statements'] del data['statements'] commons.editEntity(item, data, summary='my edit')