-
Bug
-
Resolution: Fixed
-
Medium
-
5.5
-
Self hosted
I'm sending the following via PUT using the REST API browser
{ "id": "2359303", "type": "page", "title": "NewZions", "body": { "editor": { "representation": "editor", "_expandable": { "content": "/rest/api/content/2359303" } }, "view": { "representation": "view", "_expandable": { "content": "/rest/api/content/2359303" } }, "export_view": { "representation": "export_view", "_expandable": { "content": "/rest/api/content/2359303" } }, "storage": { "value": "<p>First delivery is @ 192.168.20.something</p><p>Second delivery is @ 192.168.20.something:20080</p><p>And this was added via REST</p>", "representation": "storage", "_expandable": { "content": "/rest/api/content/2359303" } } }, "_links": { "webui": "/display/WHERE/NewZions", "tinyui": "/x/BwAk", "collection": "/rest/api/content", "base": "http://confluence.imagehawk.local:8090", "self": "http://confluence.imagehawk.local:8090/rest/api/content/2359303" }, "_expandable": { "history": "/rest/api/content/2359303/history", "container": "", "ancestors": "", "children": "/rest/api/content/2359303/child", "descendants": "/rest/api/content/2359303/descendant", "space": "/rest/api/space/WHERE", "version": "", "metadata": "" } }
The response looks like:
Response
PUT http://confluence.imagehawk.local:8090/rest/api/content/2359303 (500)
Date: Wed, 27 Aug 2014 20:24:25 GMT
Content-Encoding: gzip
X-Content-Type-Options: nosniff
Server: Apache-Coyote/1.1
X-Seraph-LoginReason: OK
Vary: User-Agent
Content-Type: application/json
Access-Control-Allow-Origin: http://confluence.imagehawk.local:8090
Transfer-Encoding: chunked
Connection: close
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type
X-AUSERNAME: mjones
{ "statusCode": 500, "message": "java.lang.NullPointerException: null" }
- is related to
-
CONFCLOUD-53656 REST API returns 500 NullPointerException on page update when "title" is missing
-
- Closed
-
Hi mjones6,
Thanks for reporting this issue.
There's one field missing in the HTTP Request Body for updating content: the version of the updated content. For the validation to succeed, that version needs to be equals to currentVersion + 1. E.g. if the current version of the content you are updating is 1, the new version would be 2.
See an example of the body request below, including the version field and just the storage representation of the body, as Steve pointed out the rest are not required:
The error code 500 and a reference to a NPE was not descriptive enough, we are sorry about that. We've been working on improving this, and currently in Confluence 5.6 the REST API does offer a more self explanatory error: 400 Bad Request, and a message of Must supply an incremented version when updating Content. No version supplied.
I hope this helps, please get in touch with us if you have further issues.
Cheers,
Esther