Hi,
I am new to Box and using the below Java code to list out the files in my folder. But, I am getting BoxAPIException as shown below.
Code:
BoxAPIConnection api = new BoxAPIConnection("Developer Token");
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
for (BoxItem.Info itemInfo : rootFolder) {
System.out.format("(%s] %s\n", itemInfo.getID(), itemInfo.getName());
}
Exception:
Exception in thread "main" com.box.sdk.BoxAPIException: Couldn't connect to the Box API due to a network error.
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:451)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:265)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:240)
at com.box.sdk.JSONIterator.loadNextPage(JSONIterator.java:74)
at com.box.sdk.JSONIterator.loadNextJsonObject(JSONIterator.java:90)
at com.box.sdk.JSONIterator.hasNext(JSONIterator.java:32)
at com.box.sdk.BoxItemIterator.hasNext(BoxItemIterator.java:28)
at com.visa.sample.FirstFirdayoftheYear.getAllPersonNames(FirstFirdayoftheYear.java:18)
at com.visa.sample.FirstFirdayoftheYear.main(FirstFirdayoftheYear.java:12)
Caused by: java.net.UnknownHostException: api.box.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:449)
... 8 more
Any help appricated.
Thanks & Regards,
VT