Skip to main content
Question

fetch the contents of root folder

  • May 21, 2025
  • 8 replies
  • 47 views

Forum|alt.badge.img

Hi Folks,

 

I am very new to Box.com and APIs, need your help here:

 

I tried to fetch the contents of root folder for my Box account by pasting the below url in browser and I am unable to get the results as  there is just a blank page. could some one please help me out here:


https://api.box.com/2.0/folders/0 \-H "Authorization: Bearer myDeveloperToken"

 

Do I need to consume this URL in an application like C# console or HTML application to make it work.

 

Thanks in advance!

8 replies

Forum|alt.badge.img

Forum|alt.badge.img

here's an example...

 

BOX_eq1pd29eclzoc2qa9pb6x7bgkyt5siud.png


Forum|alt.badge.img

Full set of collections an be retreived here! 

 

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

 


Forum|alt.badge.img

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?


Forum|alt.badge.img

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


Forum|alt.badge.img

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


Forum|alt.badge.img
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);
        });

    });
}));

Forum|alt.badge.img

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