7 Replies Latest reply on Jun 18, 2014 10:46 AM by msoltow

    Problem Updating Content via REST API

    msoltow

      We're attempting to build a content admin app that allows community administrators to select contents and alter them.  One of the options we'd like to give the admins is to change the contents' visibility, whether that means moving the items from one group to another or changing the visibility from "place" to "hidden" or "all."  However, we've run into trouble when trying to modify the "visibility" field via the REST API.  When trying to change the visibility from "place" to "all," the contents actually end up becoming "hidden."  Is this a bug in the API, or is the "visibility" field not supposed to be editable via PUT requests?  If it's not supposed to be editable, is this a feature that can be added in the future?

       

      Thank you very much.

       

      Michael

        • Re: Problem Updating Content via REST API

          Hi Michael Soltow,

          Pretty sure you will need to specify the place as well as the visibility level.  When you specify "all" that means the container for the content will be the community itself.  Therefore the "place" attribute value for the content item will need to reflect that.  Have a look at this discussion Re: How to specify Parent Space properly from RESTful POST to /contents which I think is very relevant to what you are trying to achieve.

            • Re: Problem Updating Content via REST API
              msoltow

              Hi Jason,

               

              Thanks for the response!

               

              Unfortunately, I don't seem to be able to access the linked discussion, as it says I am not authorized to view it.  In the meantime, I'm not sure what you mean by "place" attribute, as I don't seem to be able to find that field in the docs (Jive REST Rest API v3.7 → Document entity).  I've been using the "parent" attribute to specify the parent place whenever the "visibility" field was set to "place," but I've always removed it when switching the "visibility" field to "all," as the docs specify that the "parent" field must not be included if the "visibility" does not equal "place" (and I get an error if I try to leave it in).

               

              Thanks again,

              Michael

                • Re: Problem Updating Content via REST API

                  If you specify visibility : "all" or "hidden", then the parent attribute is optional.  If you specify "place", then "parent" is required.  It sounds like you are trying to provide a parent attribute in addition to all, which should break and/or not work.  Did I understand correctly? 

                    • Re: Problem Updating Content via REST API
                      msoltow

                      I've tried both leaving the "parent" field in and removing it, but neither seems to work.

                       

                      Essentially, what I am doing is:

                      1. Downloading a content object from the GET /contents endpoint
                      2. Changing the "visibility" field from "place" to "all."
                      3. Removing the "parent" field entirely.
                      4. Leaving all other fields intact.
                      5. Submitting the modified content JSON as a PUT /contents request.

                       

                      The request succeeds, but for some reason the "visibility" sometimes ends up changing to "hidden" instead of "all" (although other times it actually does change visibility correctly).  I THINK that it works for discussions but fails for documents, but I haven't tested it extensively enough to say that's the case 100% of the time.

                       

                      A quick theory: the API documentation for the PUT /contents endpoint states "For all content object types, the following fields are processed: author, content, parent, status, subject, tags, type."  Since "visibility" isn't in this list, perhaps it doesn't actually register my change to "visibility," but it does register the fact that I removed the "parent" field.  If that's the case, maybe the system assumes that a document with no place should be hidden?  Not sure if that's the case at all, though.

                       

                      Thanks for your help!

                        • Re: Problem Updating Content via REST API

                          Thanks for the clarification.  I will escalate this internally and give it a try on our sandbox to see if I can replicate

                            • Re: Problem Updating Content via REST API

                              Michael,

                               

                              I just tried this on our sandbox and I found that I am able to move content just fine.  To recreate, I did the following

                               

                              Created a Piece of Content:

                              POST /contents

                              {

                                "content": {

                                  "type": "text/html",

                                  "text": "<body><p>snippet://TEST_SNIPPET</p></body>"

                                },

                                "subject" : "Test Move",

                                "type": "document",

                                "parent" : "https://sandbox.jiveon.com/api/core/v3/places/11546"

                              }

                              then I took the JSON from that call, and removed the "parentPlace", and "parent" attribute and changed visibility to "all"

                              PUT /contents/19949

                              {

                                "id" : "2057",

                                "followerCount" : 0,

                                "likeCount" : 0,

                                "published" : "2014-06-18T14:45:00.470+0000",

                                "tags" : [ ],

                                "updated" : "2014-06-18T14:45:00.492+0000",

                                "iconCss" : "jive-icon-document",

                                "contentID" : "19949",

                                "author" : {

                                  "id" : "2059"

                                  },

                                  "displayName" : "Ryan Rutan",

                                  "emails" : [ {

                                    "jive_label" : "Email",

                                    "primary" : true,

                                    "type" : "work",

                                    "value" : "ryan.rutan@jivesoftware.com",

                                    "jive_displayOrder" : 3,

                                    "jive_summaryDisplayOrder" : 2,

                                    "jive_showSummaryLabel" : true

                                  } ],

                                  "jive" : {

                                    "level" : {

                                      "imageURI" : "https://sandbox.jiveon.com/api/core/v3/images/status/statusicon-49.gif",

                                      "name" : "Adventurer",

                                      "points" : 103

                                    },

                                    "username" : "ryanrutan"

                                  },

                                  "name" : {

                                    "familyName" : "Rutan",

                                    "formatted" : "Ryan Rutan",

                                    "givenName" : "Ryan"

                                  },

                                  "type" : "person"

                                },

                                "content" : {

                                  "text" : "<body><!-- [DocumentBodyStart:d7e592d5-9957-45b8-a257-194bd992f1ae] --><div class=\"jive-rendered-content\"><p>snippet://TEST_SNIPPET</p></div><!-- [DocumentBodyEnd:d7e592d5-9957-45b8-a257-194bd992f1ae] --></body>",

                                  "editable" : false,

                                  "type" : "text/html"

                                },

                                "replyCount" : 0,

                                "status" : "published",

                                "subject" : "Test Move",

                                "viewCount" : 1,

                                "visibleToExternalContributors" : false,

                                "parentVisible" : true,

                                "parentContentVisible" : true,

                                "authorship" : "open",

                                "categories" : [ ],

                                "visibility" : "all",

                                "outcomeTypes" : [ {

                                  "id" : "9",

                                  "name" : "wip",

                                  "confirmContentEdit" : "true",

                                  "shareable" : false,

                                  "noteRequired" : false,

                                  "urlAllowed" : false,

                                  "generalNote" : false,

                                  "confirmExclusion" : true,

                                  "confirmUnmark" : true

                                }, {

                                  "id" : "6",

                                  "name" : "success",

                                  "communityAudience" : "true",

                                  "shareable" : false,

                                  "noteRequired" : true,

                                  "urlAllowed" : false,

                                  "generalNote" : true,

                                  "confirmExclusion" : false,

                                  "confirmUnmark" : false

                                }, {

                                  "id" : "8",

                                  "name" : "official",

                                  "shareable" : false,

                                  "noteRequired" : false,

                                  "urlAllowed" : false,

                                  "generalNote" : false,

                                  "confirmExclusion" : true,

                                  "confirmUnmark" : false

                                }, {

                                  "id" : "3",

                                  "name" : "pending",

                                  "shareable" : true,

                                  "noteRequired" : true,

                                  "urlAllowed" : false,

                                  "generalNote" : false,

                                  "confirmExclusion" : false,

                                  "confirmUnmark" : false

                                }, {

                                  "id" : "7",

                                  "name" : "outdated",

                                  "shareable" : false,

                                  "noteRequired" : false,

                                  "urlAllowed" : true,

                                  "generalNote" : false,

                                  "confirmExclusion" : false,

                                  "confirmUnmark" : false

                                }, {

                                  "id" : "2",

                                  "name" : "finalized",

                                  "shareable" : false,

                                  "noteRequired" : false,

                                  "urlAllowed" : false,

                                  "generalNote" : false,

                                  "confirmExclusion" : true,

                                  "confirmUnmark" : true

                                } ],

                                "attachments" : [ ],

                                "restrictComments" : false,

                                "type" : "document"

                              }

                              Note I removed the resource links on this snippet for brevity.

                              Using PostMan I was able to preserve my requests and I was able to move a document around Jive simply by replaying my previous steps. 

                               

                              Hopefully this will help, but it appears that the API is working fine in this capacity.  Perhaps I missed a step?  I am relatively confident that the API works for this, as this is basically a move which is a very common operation, but that being said...happy to continue looking if you are seeing problems.

                               

                              Hope this helps.

                                • Re: Problem Updating Content via REST API
                                  msoltow

                                  Thanks for taking the time to replicate the problem!

                                   

                                  I went back and took the exact steps you did using curl (we're using a Java Web app, so I wanted to be sure there wasn't a problem with the JSON (de)serialization), but I am still running into the same problems.  Perhaps the issue is unique to our instance?  (Although I don't see why that would be the case.)