Join BoxWorks in San Francisco Nov 12-13! Keynotes, product demos, and Box Master Classes. Reserve your spot!

fetch the contents of root folder

Answered
New post

Comments

8 comments

  • kendomen

    You can use postman and here's a nice blog by rory on it:

    https://blog.box.com/blog/using-postman-to-get-started-with-the-content-api-and-view-api-2/

     

    0
    Comment actions Permalink
  • kendomen

    here's an example...

     

    postman.png

    0
    Comment actions Permalink
  • RoryP

    Full set of collections an be retreived here! 

     

    https://docs.box.com/docs/box-postman-collection

     

    0
    Comment actions Permalink
  • Sahil_Monga

    Thanks a lot Kendomen! It solved my problem.

     

    Could you also answer this query:

    1. I need to access this information using Javascript, so would I have to refer the two js files that were imported to Postman also before making a Get Request?

    0
    Comment actions Permalink
  • kendomen

    i've been using the box-node-js sdk to make calls in javascript.  Will that work for you?

    0
    Comment actions Permalink
  • Sahil_Monga

    Thanks Kendomen, it may work, can you share that.

    0
    Comment actions Permalink
  • kendomen
    BoxSDK = require('box-node-sdk');
    
    fs = require('fs');
    path = require('path');
    
    var PRIVATE_KEY_PATH = '';
    
    var sdk = new BoxSDK({
        clientID: 'xxxxxx',
        clientSecret: 'xxxxx',
        appAuth: {
            keyID: 'xxxxx',
            privateKey: fs.readFileSync(path.resolve(PRIVATE_KEY_PATH)),
            passphrase: 'xxxxx'
        }
    });
    
    // Get the enterprise client, used to create and manage app user accounts
    var adminAPIClient = sdk.getAppAuthClient('enterprise', 'xxxxxx');
    
    adminAPIClient.users.get(adminAPIClient.CURRENT_USER_ID, null, function(err, currentUser) {
        if(err) throw err;
        console.log('Hello, ' + currentUser.name + '!');
    });
    
    // example:  filter user by name - aken2
    var requestParam = {
        qs: {
            filter_term: 'aken2'
        }
    };
    
    adminAPIClient.get('/users', requestParam,  adminAPIClient.defaultResponseHandler(function(err, data) {
    
        data.entries.forEach(function(user) {
           console.log(user.name);
    
           var userClient = sdk.getAppAuthClient('user', user.id);
           
           // get root folder items
            userClient.folders.getItems('0', null, function(err, data) {
               console.log(data);
            });
    
        });
    }));
    0
    Comment actions Permalink
  • jiporter

    My box folders defaulted to my user directory. Can I safely move them to the root of my hard drive or must they live in the user directory to function?  Running OS X (latest version). tx

    0
    Comment actions Permalink

Please sign in to leave a comment.