Skip to main content
Box Employee
May 21, 2025 11:11 AM UTC
Question

Get SharedLink Info using the Java SDK

Hello

 

I'd like to get Info of a Shared Link using its id.

Using the Java SDK I see that there is a BoxSharedLink object, but unlike other Box* objects, it doesn't have a constructor with the API connection and an Info getter.

 

Also, I see that there is a SharedLinkAPIConnection class, but using I see no way to retreive the BoxSharedLink representing the shared link's info.

 

Please assist

    2 replies

    Box Employee
    May 21, 2025 11:11 AM UTC
    private static BoxSharedLink createSharedLink(BoxAPIConnection api, String fileId) {
            BoxFile file = new BoxFile(api, fileId);
            BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
            permissions.setCanDownload(true);
            permissions.setCanPreview(true);
            Date date = new Date();
    
            Calendar unshareAt = Calendar.getInstance();
            unshareAt.setTime(date);
            unshareAt.add(Calendar.DATE, 14);
    
            BoxSharedLink sharedLink = file.createSharedLink(BoxSharedLink.Access.COMPANY, unshareAt.getTime(), permissions);
            logger.info("shared link: " + sharedLink.getURL());
            return  sharedLink;
        }
    Translate
    Box Employee
    May 21, 2025 11:11 AM UTC

    Thanks for the reply.

    Perhaps my question needs clarification - 

    I already have an existing id of an existing shared link.

    I'd like to get info of that shared link.

    Is that possible?

    Translate