7 Replies Latest reply on May 19, 2016 10:05 AM by Bryce Gilhooly

    Updating a document




      I'm trying to update a document. I'm successfully doing that in one case, by doing the following:

      - Getting a document's contentID by calling some API

      - Getting a document's content (wrapped in lots of json) by calling /contents/{contentID}

      - Updating the actual html content of the document in memory by getting the value out of ['content']['text'] and updating the markup

      - Trying to update the document on our Jive instance by making the following call:

      curl -ib "ssocookiesfile" -XPUT -Hcontent-type:application/json --data-ascii "@updatedjsonfile" \                        


      Sorry about the formatting. Jive ate my pasted command and turned it into a table.


      So that command works in one case... but in another case I'm updating a table, and I get the following response:



      HTTP/1.1 500 Internal Server Error

      Server: Apache

      X-Jive-Request-Id: REDACTED

      X-Jive-Flow-Id: REDACTED

      X-Frame-Options: SAMEORIGIN

      P3P: CP="REDACTED"

      Content-Type: text/html;charset=UTF-8

      Content-Language: en

      Expires: Tue, 10 May 2016 01:03:08 GMT

      Content-Encoding: gzip


      X-Cnection: close

      Date: Tue, 10 May 2016 01:03:08 GMT

      Transfer-Encoding:  chunked

      Connection: close

      Connection: Transfer-Encoding

      Set-Cookie: jive.security.context="REDACTED"; Version=1; Path=/; HttpOnly;HttpOnly

      Set-Cookie: jive.user.loggedIn=true; Path=/; HttpOnly;HttpOnly


      I've redacted some parts I'm not familiar with, just in case. It also returns a bunch of garbage text (random data? encrypted data?). Again, this code will update a document without a table, but it won't update a document with a table. I thought this was because of a data-objectid attribute on a link in the table (because I don't have any more info to go on, and the docs are very light on what should actually be in the request body, or what kind of response I should expect).


      So my question is: how should I debug this? Should I be constructing some json myself to update a document? or is editing a JSON document I fetched w/a GET request to /contents/{contentID} and then PUTting it back to /contents/{contentID} correct?


      Thanks for your time.



        • Re: Updating a document

          Hmm, have you tried working with the 'editable' version of the content.. that's more suitable for fetching a version of the content that hasn't been affected by any render macros.


          1 person found this helpful
            • Re: Updating a document

              Thanks for the suggestion!


              Unfortunately it didn't help. I tried using the /editable endpoint when GETting the document and PUTting the changed document. It worked for a document without a table in it as long as I didn't use the /editable endpoint for GETting the document. I always got a 500 error when trying to update a document with a table in it.


              How can I find out what's wrong? Is there any more documentation?

                • Re: Updating a document
                  Bryce Gilhooly

                  The next thing I (personally) would test is a GET on the document with the table, then create a document with the minimum required fields, using the same data from the ['content']['text'] property to see if you still get the 500. If that works, then you at least know that the table is not causing the issue, otherwise it's something else.


                  Also make sure you're using the contentID, not the id (I made that mistake a couple times) when doing your PUT to /contents/{contentId}.


                  Hope that helps a bit.



                  • Re: Updating a document

                    I forgot to mention. The document was being returned with zero-width characters; specifically "\u200b". Removing those still gives me a 500 error when trying to update the document, but maybe there's other garbage returned that I need to clean up before making the update request too.

                      • Re: Updating a document
                        Bryce Gilhooly

                        An issue I ran into in the past was when users copy / pasted content into a document threw in some characters that made the API "unhappy". Not sure if that's the case for you, but figured I would call it out either way.

                          • Re: Updating a document

                            Hey sorry for the late response. Do you know which characters to avoid? I think I found some, but an exaustive list would be useful .

                              • Re: Updating a document
                                Bryce Gilhooly



                                Sorry, don't have any sort of list with impacted characters, I also think it had to do with specific formatting.


                                I happened to notice this pretty early during out content-creation phase, so I just reminded our Content Team to either type the content manually, or paste it as "un-formatted text" (CTRL+SHIFT+V) and style the content within the RTE; resolving the issue for me.


                                Generally speaking I don't do any sort of API / Script updating of content, unless it is "official" content created by our Content Team.


                                Sorry, I know that's not really much help