Steps to replicate the issue (include links if applicable):
- View the REST API Swagger docs at https://doc.wikimedia.org/Wikibase/master/js/rest-api/
- See the format defined in the docs for creating a new statement with the POST /entities/items/{item_id}/statements endpoint.
- Try to post the first JSON blob below to an item on the beta Wikidata site.
- See that it errors with { "code": "invalid-statement-data", "message": "Invalid statement data provided" }, despite having all the components that are declared in the Swagger docs.
This is what I tried POSTing to the endpoint, which failed:
{ "statement": { "mainsnak": { "snaktype": "value", "property": "P625", "datatype": "string", "datavalue": { "type": "string", "value": "test data" } } }, "bot": true, "tags": [], "comment": "foo" }
This is what the endpoint *actually* wanted:
{ "statement": { "mainsnak": { "snaktype": "value", "property": "P625", "datatype": "string", "datavalue": { "type": "string", "value": "test data" } }, "type": "statement" }, "bot": true, "tags": [], "comment": "foo" }
The only difference is the "type": "statement" line, which the Swagger docs do not mention/include. I only figured this out after going into the Wikibase codebase and browsing the unit tests. 😅
What happens?:
An error about an invalid statement is returned and the Swagger docs make no mention of a type attribute in the statement JSON.
What should have happened instead?:
The Swagger docs for the statements POST endpoint should include the required type key.
Software version (skip for WMF-hosted wikis like Wikipedia): Beta Wikidata site
Other information (browser name/version, screenshots, etc.):
If the same type attribute should be used on the PUT endpoint(s) for statements, those should be updated as well.