I'm struggling to follow what's needed to access files using the service account. I'm trying to access enterprise files from our custom app's (a.k.a. API) using the .NET SDK using the following code which result in 2 errors:
// Access Token and creating Client
var config = new BoxConfig(ClientID, ClientSecret,
EnterpriseID, PrivateKey, Passphrase, PublicKeyID); BoxJWTAuth boxAuth = new BoxJWTAuth(config); _adminToken = boxAuth.AdminToken(); client = boxAuth.AdminClient(_adminToken);
// Using client to get file info
BoxFile fileInfo = await client.FilesManager.GetInformationAsync(fileId);
Error 1: First few calls to Box to get a token I receive an error: "Object reference not set to an instance of an object. at Box.V2.JWTAuth.BoxJWTAuth.GetToken(String subType, String subId)". After a few retries and waiting around the code starts working again.
Error 2: On API call to get file info I received the following error: "The API returned an error [NotFound | gfi7tjgdeo5bezo9.010f07144180ddd36727a928fe468b598] not_found - Not Found".
As for Error 2, after reading through some of the comments I found out that the current user (AdminClient) was "AutomationUser_email@example.com" with a name (Postman App). Why is this? Not sure which user to use to access folders and files.
Please sign in to leave a comment.