Skip to main content
Question

BoxItem.Info returns null for various properties

  • May 21, 2025
  • 4 replies
  • 27 views

Forum|alt.badge.img

Hello,

 

I am quite new to Box API and I am just trying to write my first integration with Box Java SDK. I have followed the tutorial and managed to get a list of root folder files:

 

 

BoxFolder folder = BoxFolder.getRootFolder(api);
for (BoxItem.Info itemInfo : folder) {
if (itemInfo instanceof BoxFile.Info) {
BoxFile.Info fileInto = (BoxFile.Info) itemInfo;
// do something with the fileInfo
}
}

 

 

When I call fileInfo.getID() or fileInfo.getName(), I get the correct values. However, fileInfo.getSize() or fileInfo.getModifiedAt() always returns null. Am I doing something wrong?

 

Thanks for any help.

Filip

 

4 replies

Forum|alt.badge.img

Could you please check you need to use "fileInto" or "fileInfo" ?


Forum|alt.badge.img

That was a typo. This is the correct line:

 

BoxFile.Info fileInfo = (BoxFile.Info) itemInfo;

Forum|alt.badge.img

It's one more call.

 

       for (BoxItem.Info item : items) {
          if (item instanceof BoxFile.Info) {
              BoxFile.Info fileInto = (BoxFile.Info) item;
              System.out.println(item.getName());

              BoxFile boxFile = new BoxFile(userApi, fileInto.getID());
              System.out.println(boxFile.getInfo().getSize());
              System.out.println(boxFile.getInfo().getModifiedAt());
          }
      }

Forum|alt.badge.img

Yes, it works now. Thanks, you saved me. 🙂 I just hope the extra line does not do another call to the Box API server, which could create a performance issue if a folder contains too many files.