Hi All
Have anybody tried to list all subnodes within a folder and create folders within each subnodes using RESTful API's? I have about 1500 subnodes (Sub-folders) within the parent folder.
Thanks
Vijhay D.
Listing all subnodes and creating folders within the subnodes Posted byDevarajan, VijhayOn 04/10/2017 07:04 PM Hi AllHave anybody tried to list all subnodes within a folder and create folders within each subnodes using RESTful API's? I have about 1500 subnodes (Sub-folders) within the parent folder.ThanksVijhay D.[To post a comment, use the normal reply function]Forum:Content Server Development ForumContent Server:Knowledge Center CS16
Appu
Thanks for the prompt repsonse as usual. I wanted to create about 1500 folders from a spreadsheet and create 4 static folders within each of the 1500 folders. Technically very simple, but how could I achieve this using REST API's is the question. Since this is just a one time load, I wanted to manage the folder creation without any pagination involved. After looking into REST API's I think I will have to necessarily paginate. I will come up with something quick & dirty.
Vijhay Devarajan.
Object Importer?
Hi John
Please dont get surprised by hearing this, we dont have OI license.
Lol! Which is one reason we stopped relying on OI with our BDM product 3 or so years ago. Nice to see three friends swapping thoughts on one thread too .
You will need to paginate - list the children by batches of 100 items, until you receive the last batch:
var cgiUrl = '//server/otcs/cs', credentials = { username: 'me', password: 'secret' }, ticket;// Authenticateauthenticate(credentials) // Inspect Enterprise Volume .then(function () { return getVolume(141); }) // List children of Enterprise Volume .then(function (volume) { return listChildren(volume.id); }) // Print the child count .done(function (children) { console.log(children.length, 'children'); }) // Report failure .fail(function (request) { var error = createError(message); console.log(error.toString); });function authenticate(credentials) { return $.ajax({ type: 'POST', url: cgiUrl + '/api/v1/auth', data: credentials }); .then(function (response) { ticket = response.ticket; });}function getVolume(type) { return $.ajax({ url: cgiUrl + '/api/v1/volumes/' + 141, headers: {OTCSTicket: ticket} }) .then(function (response) { return response.data; });}function listChildren(id) { var children = []; return getAllPages(1); function getAllPages(page) { return $.ajax({ url: cgiUrl + '/api/v1/nodes/' + id + '/nodes?sort=asc_name&limit=100&page=' + page, headers: {OTCSTicket: ticket} }) .then(function (response) { Array.prototype.push.apply(children, response.data); return children.length < response.total_count ? getAllPages(page + 1) : children; }); }}function createError(request) { var response = request.responseJSON, error = new Error(response && response.error || request.responseText || 'No response available.'); error.statusCode = request.status; error.statusText = request.statusText; error.details = response && response.errorDetail; return error;}