I realise I should probably have included the example that is in the API doc so here it goes:

Creates a new claim on the item for the property P56 and a value of "ExampleString":
action=wbeditentity&id=Q42&data={"claims":[{"mainsnak":{"snaktype":"value","property":"P56","datavalue":{"value":"ExampleString","type":"string"}},"type":"statement","rank":"normal"}]}
Removes the claims from the item with the guids q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F and q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X:
action=wbeditentity&id=Q42&data={"claims":[{"id":"Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F","remove":""},{"id":"Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X","remove":""}]}
Sets the claim with the GUID to the value of the claim:
action=wbeditentity&id=Q42&data={"claims":[{"id":"Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X","mainsnak":{"snaktype":"value","property":"P56","datavalue":{"value":"ChangedString","type":"string"}},"type":"statement","rank":"normal"}]}

Addshore


On 26 February 2014 19:01, Markus Krötzsch <markus@semantic-mediawiki.org> wrote:
On 26/02/14 18:41, Jeroen De Dauw wrote:
Hey,

 >> you can create claims with wbsetclaim. But you would need to create
a valid
 >> GUID [1] yourself. The claim-GUID you send with your request needs to be
 >> <entityId>$<GUID> (e.g. Q2$5627445f-43cb-ed6d-3adb-760e66bd17ee).

 > Uh, didn't we fix this a long time ago? Client-Supplied GUIDs are evil :(

This has come up at some point, and as far as I recall, we dropped the
requirement to provide the GUID. So I suspect one can provide a claim
without a GUID, else something went wrong somewhere.

 > Requests with GUIDs that are not associated with any Statement should
be rejected

Not allowing specifying GUIDs is another topic altogether. Disallowing
them is not the intention of the current system, and needs discussion
before that is changed. This seems to be both out of scope of this
thread and be way to low on the priority list (after all, where is the
problem, its been working just fine) to spend time on.

As Daniel said: "Client-Supplied GUIDs are evil :(". My only point was that one should never use such GUIDs for new statements. Returning an error seems better than just creating a new GUID, but both would work. Mainly, we should not use externally provided GUIDs. For example, if somebody is mistaken to believe that any string of the proper format can be used, then we might get bot code where the "GUID" is based on a constant. Wikibase should better make sure that it uses quality GUIDs, which are as random as a GUID is supposed to be.


Markus


_______________________________________________
Wikidata-tech mailing list
Wikidata-tech@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-tech