Page MenuHomePhabricator

action=wbsetclaim cannot create new claim as stated in the documentation
Closed, InvalidPublic

Description

As stated in the API documentation, wbsetclaim can Creates or updates an entire Statement or Claim, but there is no id parameter that is necessary for creating an claim. I guess the documentation needs a fix.

Btw, it would be really helpful if I can specify the whole serialized claim data when creating a claim. But for now it seems that I can only do so when editing. instead of creating a claim.

Event Timeline

Restricted Application added a project: Wikidata. · View Herald TranscriptDec 11 2017, 12:20 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
thiemowmde closed this task as Invalid.Dec 11 2017, 4:00 PM
thiemowmde added a subscriber: thiemowmde.

You are supposed to provide a statement serialization. This is supposed to contain a statement GUID, which looks like (for example) Q5000$f3ab6ad1-41a5-3ec2-c232-f690bf74ee85. This statement GUID contains the entity ID which is used to identify the entity (typically the item) where the statement should be added.

If you want to add a new statement via a 3rd party tool, you should create your own random global unique identifier (GUID) that is prefixed with the entity ID where you want the statement to be saved.

I hope this helps.

It's true that the documentation visible in the API sandbox is not very nice, but it's not wrong in the way you describe it in this ticket.

I see. Thanks for your explanation, Thiemo!

Actually I'm currently working on a Wikibase API client library. This library used to edit the entities via wbeditentity requests, and now I'm
trying to break down the edits so that more detailed edit summary would be left in the edit history.

I did met with an error when trying to create a new claim with wbsetclaim, setting claim parameter to the serialized claim content. At that time, I didn't provide any GUID for the claim, thinking Wikibase might automatically assign one for this new claim, just as what would be done if I feed wbeditentity with claims that doesn't have GUID. But then I found out there is no way I can specify the subject entity via a request parameter, nor did the Wikibase server accepted my request that neglected the GUID.

Actually I ended up with wbcreateclaim, wbsetqualifier and wbsetreference invocations. But later I might switch to assigning a new GUID locally before calling wbsetclaim.