3 Replies Latest reply on Mar 19, 2014 11:32 AM by chrisbrown

    Using REST API to Move Content

    chrisbrown

      Is there a way to move content that is visible to all (i.e. does not have a parentPlace) to a parent place using REST?

        • Re: Using REST API to Move Content
          whoiskevin

          I haven't tried it via the REST API yet but you could try doing a PUT to update the content item and simply changing the visibility attribute as well as adding the parent place attribute (URL).

          • Re: Using REST API to Move Content
            pearle

            I did this using Javascript and the '/content' REST API. I worked out what to do by using Firebug to inspect what network calls were being made when I used the Jive UI to move a document.

             

            var _documentTypeId="102";
              var _url = _jive_base_absolute_url + "/__services/v2/rest/content/" + _documentTypeId + "/" + id;
            
            
              // Convert object type and Build JSON data stream - e.g. [{"objectType":14,"objectID":2009}]
              var objectType = ''; // destination is a community space or group
              if(_toSpaceType == _COMMUNITY) {
              objectType = '14';
              }
              else if(_toSpaceType == _GROUP) {
              objectType = '700';
              }
              else {
              alert("unrecognised target space type : " + _toSpaceType);
              }
            
            
              var _data = '{"objectType":' + objectType + ',"objectID":' + _toSpaceId + '}';
              var _success = true;
            
              $j.ajax({
                type: "PUT",
                url: _url,
                data: _data,
                dataType: "json",
                contentType: "application/json",
                
                success: function(data) {
              },
              // If the process fails, get the error, parse into JSON and then display the message
              error: function (jqxhr) {
              console.log(jqxhr.responseText);
              alert(jqxhr.responseText);
              _success = false;
              }
               });
            

             

            You need to know the document and target space ids (they are not the same as the ids in the db tables - e.g. internalDocId !) - I used REST API calls to get these before I did the document move.

            1 person found this helpful