Welcome to the new Box Support website. Check out all the details here on what’s changed.

Java box SDK Connection Problem

New post

Comments

2 comments

  • mwiller

    The error message says that it's an IOException caused by an UnkownHostException  for api.box.com — the docs for that exception indicate that it's thrown when the IP address cannot be resolved for a host.  Are you able to reach api.box.com when making requests manually through a tool like curl or Postman?  Is there a chance you're behind a firewall that blocks access to the API?

    0
    Comment actions Permalink
  • ajitpandit88

    Dear All,

     

    I am able to connect Box APIs using PostMan by dev token generated through portal. However, when I try to do the same thing using Box Java SDK, I am getting UnknownHostException for api.box.com and upload.box.com

     

    Since I am able to get response with PostMan, so this certainly is not a network or firewall issue. Only when I am trying to run my java code from eclipse I am facing this issue. Below is the code excerpt which uses SDK - 

     

    BoxAPIConnection api = new BoxAPIConnection("CClWUDaNOriFxEljGYGn5hmAwfpwQEUf");

    BoxUser.Info userInfo = BoxUser.getCurrentUser(api).getInfo();
    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    rootFolder.getMetadata(); ==> HERE I AM GETTING ERROR UnknownHostException

     

    I also tried to use apache HttpClient with HttpPost by pasting the API and passing token in header. But at that time I get 403 error with reason as access_denied_insufficient_permissions.

     

    Please help in figuring out the issue.

     

    Thanks in Advance.

    0
    Comment actions Permalink

Please sign in to leave a comment.