Error while using Primary Access Token instead of Developer Token
AnsweredWhere can i find developer token in box. I am new to Box APIs. Created an account and i can see Client ID, Primary Access Token and Secondary Access Token. I am getting 404 error when i use Primary Access Token to upload file to box. Is Primary Access Token same as developer token?
Any help is appreciated.
Exception:
Exception in thread "main" com.box.sdk.BoxAPIResponseException: The API returned an error code [404 | keyko6fzrenodqgu] 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:37)
-
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(String[] 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 [404 | 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)
Please sign in to leave a comment.
Comments
4 comments