Hi guys,
i want to integrate the app box of a partner company in our system. the partner company creates a collaborating
folder for the corporation. I also create a App to be able to configure the accessing on the collaborating folder.
the collaborating folder is a subfolder of the root folder.
i am confused because i can access the collaborating folder and files in there with DEVELOPER-TOKEN.
by trying the same with an programmatically created APP-USER nothing works.
It is even not possible to create a collaboration programmatically with the APP-USER on the collaborating folder.
I would appreciate any help :).
// part with the developer token
public static void main(String[] args) {
// Turn off logging to prevent polluting the output.
Logger.getLogger("com.box.sdk").setLevel(Level.OFF);
BoxAPIConnection api = new BoxAPIConnection(DEVELOPER_TOKEN);
BoxUser.Info userInfo = BoxUser.getCurrentUser(api).getInfo();
System.out.format("Welcome, %s <%s>!\n\n", userInfo.getName(), userInfo.getLogin());
fileById(api, FILE_ID);
folderById(api, FOLDER_ID);
}
private static void folderById(BoxAPIConnection api, String folderId) {
BoxFolder folder = new BoxFolder(api, folderId);
BoxFolder.Info folderInfo = folder.getInfo();
System.out.format("folder with name (%s), parent name (%s) and id (%s)\n\n", folderInfo.getName(), folderInfo.getParent().getName(), folderInfo.getID());
}
private static void fileById(BoxAPIConnection api, String fileId) {
BoxFile file = new BoxFile(api, fileId);
BoxFile.Info fileInfo = file.getInfo();
System.out.format("file with name (%s), parent name (%s) and id (%s)\n\n", fileInfo.getName(), fileInfo.getParent().getName(), fileInfo.getID());
}
// the ouputs with the developer token
//file with name (pic_caterpillar_gc45k_(0)_at87a31501.jpg), parent name (CATERPILLAR GC45K-LP-SWB100F-FPB-B154-AT87A315011274654-1R0) and id (19***phone number removed for privacy***)
//folder with name (CATERPILLAR GC45K-LP-SWB100F-FPB-B154-AT87A315011274654-1R0), parent name (Assets) and id (***number removed for privacy***37)
// part with the app user
public static void main(String[] args) {
// Turn off logging to prevent polluting the output.
Logger.getLogger("com.box.sdk").setLevel(Level.OFF);
folderById(FOLDER_ID);
}
private static BoxUser.Info createAppUser() {
BoxAPIConnection adminConnection = adminBoxConnection();
CreateUserParams params = new CreateUserParams();
params.setIsPlatformAccessOnly(true);
BoxUser.Info user = BoxUser.createAppUser(adminConnection, APP_USER_NAME, params);
System.out.format("User created with name %s and id %s\n\n", APP_USER_NAME, user.getID());
return user;
}
private static void folderById(String folderId) {
BoxAPIConnection userConnection = userBoxConnection(appUserId);
BoxFolder folder = new BoxFolder(userConnection, folderId);
BoxFolder.Info folderInfo = folder.getInfo();
System.out.format("folder with name (%s), parent name (%s) and id (%s)\n\n", folderInfo.getName(), folderInfo.getParent().getName(), folderInfo.getID());
}
private static BoxDeveloperEditionAPIConnection userBoxConnection(String userId) {
return BoxDeveloperEditionAPIConnection.getAppUserConnection(userId, clientId, clientSecret, jwtEncrptionPrferences(), accessTokenCache);
}
// outputs with the app user
Exception in thread "main" com.box.sdk.BoxAPIException: The API returned an error code: 404
{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"item","message":"Invalid value 'd_31997050337'. 'item' with value 'd_31997050337' not found"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Not Found","request_id":"***number removed for privacy***159663d44a5452"}
at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:70)
at com.box.sdk.BoxJSONResponse.(BoxJSONResponse.java:30)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:435)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:221)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:196)
at com.box.sdk.BoxFolder.getInfo(BoxFolder.java:253)
at com.box.sdk.example.MainConnellJwtEnterprise.folderById(MainConnellJwtEnterprise.java:43)
at com.box.sdk.example.MainConnellJwtEnterprise.main(MainConnellJwtEnterprise.java:37)
Thanks.