Box Java API returns 409 on getInfo
Hi,
We are trying to use Box SDK to read files from Box. But in some cases we are getting 409 error, without any details. We are not trying to write\edit something, only read metadata. This usually happens when we are trying to get root like this:
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
BoxFolder.Info info = rootFolder.getInfo();
Message:
com.box.sdk.BoxAPIResponseException: The API returned an error code [409]
If after first failure we try to resend request - it fails with
An error occurred in Box account details: The API returned an error code [400] invalid_grant - Refresh token has expired
That's how we are restoring connection and refreshing token.
public BoxAPIConnection getAPI(Long connectorId) throws ConnectorException {
String state = //get state from DB
BoxAPIConnection api = BoxAPIConnection.restore(boxSettings.getClientId(), boxSettings.getClientSecret(), state);
api.addListener(new BoxAPIConnectionListener() {
@Override
public void onRefresh(BoxAPIConnection api) {
try {
log.warn(format("Refreshing BOX token for %d", connectorId));
String state = api.save();
//Save state to DB
}
catch (Exception e) {
log.error("An error occurred while saving box connector settings: " + e.getMessage(), e);
}
}
@SneakyThrows
@Override
public void onError(BoxAPIConnection api, BoxAPIException error) {
String state = //get state from DB
api.restore(state);
log.error("An error occurred in Box account details: " + error.getMessage());
}
});
return api;
Thanks!
BR,
Danila
Please sign in to leave a comment.
Comments
0 comments