Welcome to the new Box Support website. Check out all the details here on what’s changed.

Upload file in Subfolder

Answered
New post

Comments

3 comments

  • mwiller

    Hi  — this is due to the fact that your Box account that you access through the browser (our web application UI) is actually a totally different user account from the service account associated with your application.  The folders in one account are not automatically shared between these two accounts — you'll need to either invite the service account to collaborate on the folder in your own account (to give it access to that folder), or create a new folder in the service account's root folder to store files in and then invite your personal account to collaborate on that folder.  I personally think the second option is a bit easier, since you already have API access to the service account — the code to create and collaborate the folder from the service account would look something like this:

     

    // Create a new subfolder in the service account's root folder
    BoxFolder rootFolder = BoxFolder.getRootFolder(serviceAccountClient);
    BoxFolder.Info subfolder = rootFolder.createFolder("Shared With Service Account");
    
    // Collaborate your personal account into the new subfolder
    // and give your personal account co-owner permissions on the folder
    // NOTE: REPLACE THE EMAIL ADDRESS BELOW WITH YOUR ACCOUNT LOGIN EMAIL String myLoginEmail = "yourAccountLoginEmailAddress@example.com"; subfolder.getResource().collaborate(myLoginEmail, BoxCollaboration.Role.CO_OWNER);

    You should then see a folder in your personal account called "Shared With Service Account" that both your personal account and the service account have access to!

    0
    Comment actions Permalink
  • Jason

    Nice explanation !

    0
    Comment actions Permalink
  • nag6659

    My dev application and my folder both created by with my user but I am receiving below error.

     

    boxsdk.exception.BoxAPIException: Message: Not Found
    Status: 404
    Code: not_found
    Request ID: 9mgf8eg0qy9jc8nf
    Headers: {'content-length': '322', 'age': '2', 'strict-transport-security': 'max-age=31536000', 'vary': 'Accept-Encoding', 'connection': 'keep-alive', 'cache-control': 'no-cache, no-store', 'date': 'Mon, 04 Mar 2019 10:42:49 GMT', 'content-type': 'application/json'}
    URL: https://upload.box.com/api/2.0/files/content
    Method: POST
    Context Info: {u'errors': [{u'reason': u'invalid_parameter', u'message': u"Invalid value 'd_6***phone number removed for privacy***'. 'parent' with value 'd_6***phone number removed for privacy***' not found", u'name': u'parent'}]}

     

    Please help me on this.

    0
    Comment actions Permalink

Please sign in to leave a comment.