Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

getSharedLink is returning garbage

Answered
New post

Comments

3 comments

  • mwiller

     Hey, I'm Matt and my team maintains the Box Java SDK — I'm happy to help you out here!  The output you're seeing isn't garbage, it's just Java telling you that what you're dealing with is an Object of some sort that doesn't have an overridden .toString() method (specifically one with type com.box.sdk.BoxSharedLink).  If you look at the Javadocs for the getSharedLink() method, you'll see that it returns this type of object, not a String.  To get the actual URL string, you'll need to something like this:

     

    BoxSharedLink sharedLink = itemInfo.getSharedLink();
    if (sharedLink != null) {
        String sharedLinkURL = sharedLink.getURL();
        // do something with the shared link URL
    }
    0
    Comment actions Permalink
  • LandC

    Matt,

     

    Thank you for your prompt response.  My apologies for such a simple oversight.  I used your code below and it worked like a charm!

     

    LandC

    0
    Comment actions Permalink
  • mwiller

    No problem — glad you got it working!

    0
    Comment actions Permalink

Please sign in to leave a comment.