Skip to main content
Question

The API returned an error [NotFound | Xxxxxxxxx.] not_found - Not Found while uploading a file using creating admin client with JWTAuth

  • May 22, 2025
  • 2 replies
  • 29 views

Forum|alt.badge.img

Hello, I am uploading a file using below code. But I am getting an exception from uploadAsync method as 

"The API returned an error [NotFound | Xxxxxxxxx.] not_found - Not Found"

 

var config = new BoxConfigBuilder(clientID
                                , clientSecret
                                , enterpriseID
                                , privateKey
                                , passphrase
                                , publicKeyID)
                .Build();
 
            var boxJWT = new BoxJWTAuth(config);
            var token = await boxJWT.AdminTokenAsync();
            var client = boxJWT.AdminClient(token);
  
            using (FileStream stream = new FileStream(file2ToUpload, FileMode.Open))
            {
                BoxFileRequest req = new BoxFileRequest()
                {
                    Name = $"Book2_{DateTime.Now.ToString("MM/dd/yyyy").Replace("/", "_")}.xlsx",
                    Parent = new BoxRequestEntity() { Id = folderID }
                };
 
                var newFile = await client.FilesManager.UploadAsync(req, stream);
            }

If I upload using developer token, it works fine.

What could be wrong?

 

 

2 replies

Forum|alt.badge.img

I imagine what's happening is that your service account that was created when you made your Box app is not collaborated into the folder you want to upload the file into. Dev tokens tie back to your user... 

Alex, Box Developer Advocate


Forum|alt.badge.img

Yes, That did the trick. I had to add the service account as collaborator to the folder I wanted to upload the file. I was under impression that when I created app that app has access to upload any folder in my account.