1 Reply Latest reply on Jun 3, 2020 8:43 PM by john_reynolds

    How can I update a blog post with PUT method?

    julianfv Novice

      Hi everyone,


      I have tried to update a blog post from the JavaScript console, but I have consistently gotten the following error message:


      HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax.


      My approach was as follows:


      1. Define new XMLHttpRequest object:

      var a = new XMLHttpRequest();


      2. Open 'PUT'

      a.open('PUT', 'https://DOMAIN.com/api/core/v3/contents/POST_ID'); (Note: for confidentiality reasons, I replaced the first part of the URL with DOMAIN. POST_ID is a placeholder for the contentID of the blog post I would like to update)


      3. Define body

      let json = JSON.stringify({

           content: {'type': 'text/html', 'text': '<p>New content of post</p>'}

           subject: 'Some subject',

           type: 'post',

           parent: 'https://DOMAIN.com/api/core/v3/places/BLOG_ID'



      4. Set RequestHeader

      a.setRequestHeader('Content-Type', 'application/json');


      5. Send request



      I have been trying to find a solution, tested the 'DELETE' method (which worked), and would really appreciate if someone could help or at least steer me in the right direction.


      All the best,


        • Re: How can I update a blog post with PUT method?
          john_reynolds Guru

          I think the issue here is that when you create content with POST /contents, this endpoint can take the minimum parameters to create the post.


          Once you have a post and want to update it, you have to save the whole Content object back to Jive


          For example, if you want to update, the best practice is to

          1. Get the Content JSON object with GET /contents/<id>
          2. Take this JSON return object, modify it, and take it exactly as the input of PUT /contents/<id>

          Can you try that?

          1 person found this helpful