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&nbsp;@ 192.168.20.something</p><p>Second delivery is&nbsp;@ 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"
      }
      

            [CONFSERVER-34716] REST API throws 500 with null pointer exception

            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:

            {
              "id": "557060",
              "type": "page",
              "title": "NewZions",
              "version": {
               "number": "2"
              },
              "body": {
                "storage": {
                  "value": "<p>First delivery is&nbsp;@ 192.168.20.something</p><p>Second delivery is&nbsp;@ 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 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

            sthr (Inactive) added a comment - 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: { "id" : "557060" , "type" : "page" , "title" : "NewZions" , "version" : { "number" : "2" }, "body" : { "storage" : { "value" : "<p>First delivery is&nbsp;@ 192.168.20.something</p><p>Second delivery is&nbsp;@ 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 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

            Thanks for the bug report Mark, at a guess I'd say the extraneous entries for body are causing problems, remove the following from the body map, you only require the storage representation to update, so remove :

               "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"
                  }
                },
            

            Steve Lancashire (Inactive) added a comment - - edited Thanks for the bug report Mark, at a guess I'd say the extraneous entries for body are causing problems, remove the following from the body map, you only require the storage representation to update, so remove : "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" } },

              easenjo sthr (Inactive)
              ce5b0617f3fa Mark Jones
              Affected customers:
              0 This affects my team
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: