Hi,
I am attempting to make a script using the .NET SDK that will automatically login and upload a file when run. I am having trouble understanding how to get JWT with OAuth working. I've used the dev token successfully to test my code, but can't seem to figure out the proper way to use the client created with Adminclient and the JSON Config file. Should I be making an As-User to be able to call Filesmanager.uploadasync()? Below is my code. I get the same error when using a service account client and an App User.
Here is the error I am receiving:
exception when uploading: Box.V2.Exceptions.BoxException: The API returned an error [NotFound | 1xzugdfv55z9c2d5] not_found - Not Found
at Box.V2.Extensions.BoxResponseExtensions.ParseResults[T](IBoxResponse`1 response, IBoxConverter converter)
at Box.V2.Managers.BoxResourceManager.ToResponseAsync[T](IBoxRequest request, Boolean queueRequest)
at Box.V2.Managers.BoxFilesManager.UploadAsync(BoxFileRequest fileRequest, Stream stream, IEnumerable`1 fields, Nullable`1 timeout, Byte[] contentMD5, Boolean setStreamPositionToZero, Uri uploadUri)
Any help is appreciated, thanks!
// Read in config file
IBoxConfig configJWT = null;
using (FileStream fs = new FileStream(@"mypath", FileMode.Open))
{
configJWT = BoxConfig.CreateFromJsonFile(fs);
}
// Create JWT auth using config file
var boxJWT = new BoxJWTAuth(configJWT);
// Create admin client
var adminToken = boxJWT.AdminToken();
BoxClient clientJWT = boxJWT.AdminClient(adminToken);
// Make API calls/work with files
try
{
newFile = await appUserClient.FilesManager.UploadAsync(req, stream);
}
catch(BoxException bex)
{
}