3 Replies Latest reply on Jun 7, 2017 1:55 PM by Ryan Rutan

    Unexpected behavior of edition the attachments of jive discussion

    xias4

      API: /api/core/v3/contents/{contentID}

      Method: PUT

      Issue description

      Problem:

      1. The upload of new attachment to Jive discussion will cause the removal of all old attachments.
      2. The change of attachment list of content through the API is quite unstable, for most time, it has no effect at all.

       

      Expected behavior:

      1. The old attahments should be totally managable through the JSON part of the request.
      2. The upload of new attachment should be appended to the attachment list instead of replacing it

      And it's normally the expected behavior acccording to the documentation:

      Multipart of subtype form-data that will include a section with a Content describing the content to be updated and another section for each file being uploaded.

      Current Request IO

      CASE 1: Upload new attachment

      Request:

      JSON PART:

       

      {
          attachments:[
              {
                  contentType: "image/jpeg",
                  doUpload: false,
                  id: 3505,
                  name: "IMG_1092.PNG",
                  size: 668567,
                  url:".../api/core/v3/attachments/3505/data"
              }
          ],
          categories: []
          content: {
              text:"Test hhhh jhcvjjjj",
              type:"text/html"
          }
          id: 3314;
          parent: ".../api/core/v3/places/4661",
          question: 1,
          resolved: "open",
          subject: "Test hhhh jhcvjjjj Data Domain",
          tags: [
              "datadomain"
          ],
          type: "discussion",
          visibility: "place",
          visibleToExternalContributors: false
      }
      

       

      Binary data PART:

      Binary data of image with content-type: image/jpg

      Response:

       

      {
          attachments:[
              {
                  contentType: "image/jpeg";
                  doUpload: 0;
                  id: 3506;
                  name: "IMG_1091.JPG";
                  size: 725730;
                  url: ".../api/core/v3/attachments/3506/data";
              }
          ],
          categories: [],
          content =     {
              editable = 0;
              text = "<body><!-- [DocumentBodyStart:d026a9c2-18ce-43c5-af3d-fd5194496fa2] --><div class=\"jive-rendered-content\"><span>Test hhhh jhcvjjjj</span></div><!-- [DocumentBodyEnd:d026a9c2-18ce-43c5-af3d-fd5194496fa2] --></body>";
              type = "text/html";
          };
          id = 3314;
          parent = ".../api/core/v3/places/4661";
          question = 1;
          resolved = open;
          subject = "Test hhhh jhcvjjjj Data Domain";
          tags =     (
              datadomain
          );
          type = discussion;
          visibility = place;
          visibleToExternalContributors = 0;
      }
      

       

      We can see that the old attachment has been removed, only the new uploaded attachment has been added to the attachment list.

      Expected Response

       

      {
          attachments:[
              {
                  contentType: "image/jpeg";
                  doUpload: 0;
                  id: 3506;
                  name: "IMG_1091.JPG";
                  size: 725730;
                  url: ".../api/core/v3/attachments/3506/data";
              },
              {
                  contentType: "image/jpeg",
                  doUpload: false,
                  id: 3505,
                  name: "IMG_1092.PNG",
                  size: 668567,
                  url:".../api/core/v3/attachments/3505/data"
              }
          ],
          categories: [],
          content =     {
              editable = 0;
              text = "<body><!-- [DocumentBodyStart:d026a9c2-18ce-43c5-af3d-fd5194496fa2] --><div class=\"jive-rendered-content\"><span>Test hhhh jhcvjjjj</span></div><!-- [DocumentBodyEnd:d026a9c2-18ce-43c5-af3d-fd5194496fa2] --></body>";
              type = "text/html";
          };
          id = 3314;
          parent = ".../api/core/v3/places/4661";
          question = 1;
          resolved = open;
          subject = "Test hhhh jhcvjjjj Data Domain";
          tags =     (
              datadomain
          );
          type = discussion;
          visibility = place;
          visibleToExternalContributors = 0;
      }
      

      CASE 2: Removal of attachments:

      Original object in JSON

       

      {{
        "id" : "3314",
        "categories" : [
      
      
        ],
        "subject" : "Test hhhh jhcvjjjj Data Domain",
        "parent" : "https:\/\/...\/api\/core\/v3\/places\/4661",
        "resolved" : "open",
        "tags" : [
          "datadomain"
        ],
        "type" : "discussion",
        "visibility" : "place",
        "attachments" : [
          {
            "size" : 75746,
            "id" : "3512",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3512\/data",
            "contentType" : "audio\/mp4",
            "doUpload" : false,
            "name" : "Audio07-04-2017 11:38-575.m4a"
          },
          {
            "size" : 73251,
            "id" : "3513",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3513\/data",
            "contentType" : "audio\/mp4",
            "doUpload" : false,
            "name" : "Audio07-04-2017 11:44-043.m4a"
          },
          {
            "size" : 668567,
            "id" : "3514",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3514\/data",
            "contentType" : "image\/jpeg",
            "doUpload" : false,
            "name" : "IMG_1092.PNG"
          },
          {
            "size" : 166,
            "id" : "3515",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3515\/data",
            "contentType" : "application\/zip",
            "doUpload" : false,
            "name" : "http%3A%2F%2FTtttt.link.zip"
          }
        ],
        "question" : true,
        "visibleToExternalContributors" : false,
        "content" : {
          "type" : "text\/html",
          "text" : "<body><!-- [DocumentBodyStart:6eabda07-b73f-46e9-bdf6-809a840233ce] --><div class=\"jive-rendered-content\"><span>Test hhhh jhcvjjjj<\/span><\/div><!-- [DocumentBodyEnd:6eabda07-b73f-46e9-bdf6-809a840233ce] --><\/body>",
          "editable" : false
        }
      }
      

      Request:

       

      {
        "id" : "3314",
        "categories" : [
      
      
        ],
        "subject" : "Test hhhh jhcvjjjj Data Domain",
        "parent" : "https:\/\/...\/api\/core\/v3\/places\/4661",
        "resolved" : "open",
        "tags" : [
          "datadomain"
        ],
        "type" : "discussion",
        "visibility" : "place",
        "attachments" : [
          {
            "size" : 75746,
            "id" : "3512",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3512\/data",
            "contentType" : "audio\/mp4",
            "doUpload" : false,
            "name" : "Audio07-04-2017 11:38-575.m4a"
          },
          {
            "size" : 668567,
            "id" : "3514",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3514\/data",
            "contentType" : "image\/jpeg",
            "doUpload" : false,
            "name" : "IMG_1092.PNG"
          }
        ],
        "question" : true,
        "visibleToExternalContributors" : false,
        "content" : {
          "type" : "text\/html",
          "text" : "Test hhhh jhcvjjjj"
        }
      }

      Response:

       

      {
        "id" : "3314",
        "categories" : [
      
      
        ],
        "subject" : "Test hhhh jhcvjjjj Data Domain",
        "parent" : "https:\/\/...\/api\/core\/v3\/places\/4661",
        "resolved" : "open",
        "tags" : [
          "datadomain"
        ],
        "type" : "discussion",
        "visibility" : "place",
        "attachments" : [
          {
            "size" : 75746,
            "id" : "3512",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3512\/data",
            "contentType" : "audio\/mp4",
            "doUpload" : false,
            "name" : "Audio07-04-2017 11:38-575.m4a"
          },
          {
            "size" : 73251,
            "id" : "3513",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3513\/data",
            "contentType" : "audio\/mp4",
            "doUpload" : false,
            "name" : "Audio07-04-2017 11:44-043.m4a"
          },
          {
            "size" : 668567,
            "id" : "3514",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3514\/data",
            "contentType" : "image\/jpeg",
            "doUpload" : false,
            "name" : "IMG_1092.PNG"
          },
          {
            "size" : 166,
            "id" : "3515",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3515\/data",
            "contentType" : "application\/zip",
            "doUpload" : false,
            "name" : "http%3A%2F%2FTtttt.link.zip"
          }
        ],
        "question" : true,
        "visibleToExternalContributors" : false,
        "content" : {
          "type" : "text\/html",
          "text" : "
      
      Test hhhh jhcvjjjj<\/span><\/div><\/body>",
          "editable" : false
        }
      }

      Expected response

       

      {
        "id" : "3314",
        "categories" : [
      
      
        ],
        "subject" : "Test hhhh jhcvjjjj Data Domain",
        "parent" : "https:\/\/...\/api\/core\/v3\/places\/4661",
        "resolved" : "open",
        "tags" : [
          "datadomain"
        ],
        "type" : "discussion",
        "visibility" : "place",
        "attachments" : [
          {
            "size" : 75746,
            "id" : "3512",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3512\/data",
            "contentType" : "audio\/mp4",
            "doUpload" : false,
            "name" : "Audio07-04-2017 11:38-575.m4a"
          },
          {
            "size" : 668567,
            "id" : "3514",
            "url" : "https:\/\/...\/api\/core\/v3\/attachments\/3514\/data",
            "contentType" : "image\/jpeg",
            "doUpload" : false,
            "name" : "IMG_1092.PNG"
          }
        ],
        "question" : true,
        "visibleToExternalContributors" : false,
        "content" : {
          "type" : "text\/html",
          "text" : "Test hhhh jhcvjjjj"
        }
      }

       

      According to what is observed from the response, despite the change of content of attachment in the request, no change has been applied at all on the server side.

       

      Can anyone help me with this? Thanks in advance.