As a tool developer I want to change elements of a statement so that my tool can improve ontology on Wikibase instance
PATCH /entities/properties/{property_id}/statements/{statement_id}
PATCH /statements/{statement_id}
Notes
- Request includes a JSON Patch document describing wanted changes
- client can provide additional edit metadata: mediawiki tags, edit summary text to append to the automated summary, and a bot edit flag, like in PATCH /entities/items/{item_id}/statements/{statement_id}
- Response to a success request will include the new statement data, inclduing the ETag (revision ID) and modification timestamp
- "Automated edit summary" related to the edit to be of form: /* wbsetclaim-update:1||1 */ [[Property:P123]]: VALUE_FORMATTED (exactly the same thing as for statement on items)
- Handle HTTP conditional request headers as in PATCH /entities/items/{item_id}/statements/{statement_id}
- Handle user authentication/authorization like in PATCH /entities/items/{item_id}/statements/{statement_id}
- The functionality already exist for statements on items: https://doc.wikimedia.org/Wikibase/master/js/rest-api/#operations-statements-patch_entities_items__item_id__statements__statement_id_
Error cases to consider (expected to match the errors of PATCH /entities/items/{item_id}/statements/{statement_id})
HTTP response code | response payload | |
---|---|---|
Property does not exist - the "statement subject" property | 404 | "code": "property-not-found" "message": "Could not find a property with the ID: {property_id}" |
Statement does not exist | 404 | "code": "statement-not-found" "message": "Could not find a statement with the ID: {statement_id}" |
Invalid statement ID | 400 | "code": "invalid-statement-id" "message": "Not a valid statement ID: {statement_id}" |
Invalid property ID - the "statement subject" property | 400 | "code": "invalid-property-id" "message": "Not a valid property ID: {property_id}" "context": {"property-id": "{property-id}"} |
Invalid edit tag | 400 | "code": "invalid-edit-tag" "message": "Invalid MediaWiki tag: {tag}" |
Edit comment/summary too long | 400 | "code": "comment-too-long" "message": "Comment must not be longer than {limit} characters" |
Request would change the ID of the statement | 400 | "code": "invalid-operation-change-statement-id" "message": "Cannot change the ID of the existing statement" |
Request would change the property (predicate) of the statement | 400 | "code": "invalid-operation-change-property-of-statement" "message": "Cannot change the property of the existing statement" |
Missing a mandatory field in JSON Patch (e.g. "path", "op") | 400 | "code": "missing-json-patch-field" "message": "Missing '{field}' in JSON patch" "context": { "operation": { <PATCH_OBJECT> }, "field": <MISSING_FIELD> } |
Operation in the JSON Patch is not valid | 400 | "code": "invalid-patch-operation" "message": "Incorrect JSON patch operation: '{op}'" "context": { "op": "{op}", path": "/some/path" } |
Value provided in the JSON Patch operation is of incorrect type | 400 | "code": "invalid-patch-field-type" "message": "The value of '{field}' must be of type string" "context": { "operation": { <PATCH_OBJECT> }, "field": <FIELD> } |
Provided JSON Patch document is not valid (generic error) | 400 | "code": "invalid-patch" "message": "The provided patch is invalid" |
Cannot apply JSON Patch as target path not found | 409 | "code": "patch-target-not-found" "message": "Target '{target}' not found on the resource" "context": { "operation": { <PATCH_OBJECT> }, "field": <PATH> } |
Test operation of JSON Patch failed | 409 | "code": "patch-test-failed" "message": "Test operation in the provided patch failed. At path '{path}' expected '{expected}', actual: '{actual}'" "context": { "operation": { <PATCH_OBJECT> }, "actual-value": <ACTUAL> } |
Request payload is not JSON | 415 | "code": "unsupported-content-type" "message": "Unsupported Content-Type: '{content_type}'" |
Statement after changes missing mandatory field | 422 | "code": "patched-statement-missing-field" "message": "Mandatory field missing in the patched statement: '{field}''" "context": { "path": "{field}"} |
Value in the statement data after changes is invalid | 422 | "code": "patched-statement-invalid-field" "message": "Invalid input for '{field}' in the patched statement" "context": { "path": "{field}", "value": "{value}"} |
... | ... | ... |
Possibly relevant pointers:
- Suggestion in 2020 Wikibase REST API proposal: https://wmde.github.io/wikibase-rest-api-proposal/#/statements/patch_statements__statement_id_
- How Wikibase Action API handles this: https://www.wikidata.org/w/api.php?action=help&modules=wbsetclaim