2 Replies Latest reply on Oct 31, 2019 4:15 PM by john_reynolds

    Why I update document content, it loses its place assignment.

    jwd2bc

      Hi All,

       

      When I update an existing document's contents, it loses its place assignment.  It should only update the fields I specify .. or this is my expectation.

       

      What am I doing wrong:

       

      e.g. document at /docs/DOC-123 with Jive API ID of '999'
      I do a PUT to PUT https://HOST/api/core/v3/contents/999with a payload containing, content, subject, and type.

       

      Here's a snippet of python code that does this:

       

          url = "{}/contents/{}".format(JIVE_URL, content_jive_id)    
          payload = {
      
              "content": {"type": "text/html", "text": "{}".format(body)},
      
              "subject": "{}".format(title),
      
              "type": "document",
      
          }
      
          files = {
      
              "json": (None, json.dumps(payload), "application/json"),
      
              #  'file': (os.path.basename(file), open(file, 'rb'), 'application/octet-stream')
      
          }
      
          response = requests.put(url, files=files, headers=HEADERS)

       

       

        • Re: Why I update document content, it loses its place assignment.
          jwd2bc

          I turns out, you must ALSO include the parent field in the payload.

           

              payload = {

                  "content": {"type": "text/html", "text": "{}".format(body)},

                  "subject": "{}".format(title),

                  "parent": "https://HOST/api/core/v3/places/{}".format(

                      parent_jive_id

                  ),

                  "type": "document",

              }

            • Re: Why I update document content, it loses its place assignment.
              john_reynolds

              Yes, exactly.

               

              When you say this ...

               

              When I update an existing document's contents, it loses its place assignment.  It should only update the fields I specify .. or this is my expectation.

               

              ... it's not exactly true. Jive updates what you specify but will blank out what you don't specify. With other objects like Users, this is often caught with errors when required fields are not specified and Jive thinks you're trying to save a "blank" in a required field.

               

              Easy enough fix, though: it's  best practice in Jive for Updates to follow this:

               

              1. Get the Content JSON using GET /contents/<id>
              2. Update the JSON element you need to change
              3. Put the same JSON back with PUT /contents/<id>