a partner integration does not have the developer token as it already comes with 2 access tokens out of the Box. It is also not meant for uploading files.
You will want to create a Custom Application probably, and then you can create a Developer Token via the interface.
Thank You..I created custom app and now i can see the developer token access. Issues still existing with developer token as well. Not sure what mistake i am doing in my code...
My JAVA Code:
import java.io.FileInputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.box.sdk.BoxAPIConnection;
import com.box.sdk.BoxFile;
import com.box.sdk.BoxFolder;
import com.box.sdk.BoxItem;
import com.box.sdk.BoxUser;
public class BoxTest {
private static final String DEVELOPER_TOKEN = "------";
private static final int MAX_DEPTH = 3;
public static void main(Stringg] args) throws Exception {
// Turn off logging to prevent polluting the output.
Logger.getLogger("com.box.sdk").setLevel(Level.OFF);
BoxAPIConnection client = new BoxAPIConnection(DEVELOPER_TOKEN);
BoxUser.Info userInfo = BoxUser.getCurrentUser(client).getInfo();
System.out.format("Welcome, %s <%s>!\n\n", userInfo.getName(), userInfo.getLogin());
// Set upload values
String filePath = "C:/eclipse/test.txt";
String fileName = "Test.txt";
String folderId = "Test";
// Select Box folder
BoxFolder folder = new BoxFolder(client, folderId);
// Upload file
FileInputStream stream = new FileInputStream(filePath);
BoxFile.Info newFileInfo = folder.uploadFile(stream, fileName);
stream.close();
}
}
Exception:
Exception in thread "main" com.box.sdk.BoxAPIResponseException: The API returned an error code d404 | z4yf3ffzrfk06wfb] not_found - Not Found
at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:92)
at com.box.sdk.BoxJSONResponse.(BoxJSONResponse.java:32)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:579)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:354)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:329)
at com.box.sdk.BoxFolder.uploadFile(BoxFolder.java:516)
at com.box.sdk.BoxFolder.uploadFile(BoxFolder.java:441)
at box.caseroads.BoxTest.main(BoxTest.java:39)
You need to provide a valid Box folder ID, try "0" for your root folder.
Yeah...I was able to upload file for first time with the code...Thank You Cbette. Appreciate your help.