Skip to main content
Question

weblinks

  • May 22, 2025
  • 2 replies
  • 15 views

Forum|alt.badge.img

How to retrieve weblinks from root folder with box  java sdk? 

2 replies

Forum|alt.badge.img

hi Ritika

You can use the BoxItem.Info.getType() to work out the type of items in the folder. Either File,Folder or Weblink

https://github.com/box/box-java-sdk/blob/main/doc/folders.md#get-a-folders-items

For root folder you could do something like this:

BoxFolder folder = new BoxFolder(api, "0");
for (BoxItem.Info itemInfo : folder) {
if (itemInfo.getType().equals("web_link") {
BoxWeblink.Info weblinkInfo = (BoxWeblink.Info) itemInfo;
// Do something with the weblink.
} else if (itemInfo.getType().equals("file") { BoxFile.Info fileInfo = (BoxFile.Info) itemInfo; // Do something with the file. } else if (itemInfo.getType().equals("folder") { BoxFolder.Info folderInfo = (BoxFolder.Info) itemInfo; // Do something with the folder. } }

Best regards
Peter Christensen, Platform Solutions Engineer, Box


Forum|alt.badge.img

Thanks 363373027287