BoxAPIConnection exception
Hi,
I am new to the box api. I have gone through the java box sdk and trying out to get connection with box with java client. I am simply printing the root folder in the below code but it is throwing an error:
package com.box.api.test;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import com.box.sdk.BoxAPIConnection;
import com.box.sdk.BoxConfig;
import com.box.sdk.BoxFolder;
public class BoxAPIConnectionTest {
public static void main(String[] args) throws IOException {
Reader reader = new FileReader("resources/config.json");
BoxConfig boxConfig = BoxConfig.readFrom(reader);
BoxAPIConnection api = new BoxAPIConnection(boxConfig);
BoxFolder root_Fol=BoxFolder.getRootFolder(api);
System.out.println(root_Fol.getInfo().getID());
}
}
Error:
Exception in thread "main" com.box.sdk.BoxAPIResponseException: The API returned an error code [401 | .08e718937be17e68094d8f7a2c2ee84c]
at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:92)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:577)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:354)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:329)
at com.box.sdk.BoxFolder.getInfo(BoxFolder.java:288)
at com.box.api.test.BoxAPIConnectionTest.main(BoxAPIConnectionTest.java:16)
could you please assist that what would be the issue in my code?
-
Hi ,
This may be due to a few things - let's check off a few of the most common:
- Within the scopes of your application can you try setting "read and write all folders" to on if not already set.
- Did you (or your enterprise admin) authorize the app to work in the enterprise? You'll also need to reauthorize whenever there are scope changes to the app. If a JWT app isn't authorized it'll prevent you from making API calls.
Hopefully one of those is the cause,
Jon
-
Hi ,
Thanks for the response.
I have made the configuration changes to my application as below:
App Type: Enterprise Integration
Auth Method: OAuth2.0 JWT
Application Access: Enterprise
App Scopes: as below
application scopesand also authorized this app twice but still couldn't. and my self is the admin and there were no other users created.
サインインしてコメントを残してください。
コメント
2件のコメント