cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a Dropboxdirectory from code

Create a Dropboxdirectory from code

notstrom
Helpful | Level 6
Go to solution

Hi

 

I want to create a directory from a C# program in Dropbox. When I run this from my desktop PC everything works perfectly. As soon as I run the program from my laptop I get the error message:

 

Dropbox.Api.BadInputException: "Error in call to API function "files/create_folder_v2": Your app is not permitted to access this endpoint because it does not have the required scope 'files.content.write'. The owner of the app can enable the scope for the app using the Permissions tab on the App Console."

 

In the app console I set the file permissions to Files-Metadata and Filed-Content to Write. The Permssion Type is Scoped App.

 

I create a directory with the following code:

 

 

 

 

 using (var dbx = new DropboxClient(accessToken))
            {
                string folderPath = destinationPath.Replace("\\", "/").ToLower();
                if (folderPath.EndsWith("/"))
                    folderPath = folderPath.Substring(0, folderPath.Length - 1);
                try
                {
                    var fldMetadata = await dbx.Files.CreateFolderV2Async(folderPath);
                    if (fldMetadata.Metadata.IsFolder)
                        retCode = fldMetadata.Metadata.Name;
                    else
                        retCode = "ERROR cannot create " + folderPath;
                 }
             }

 

 

 

 I hope you can help me how to work around this error.

Best regards

Peter

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

That error indicates that you're using an access token/app that does not have the 'files.content.write' scope enabled.

 

To resolve that, you'll need to enable that 'files.content.write' scope for that particular app, by using the "Permissions" tab of the app's page on the App Console, while signed in to the account that owns that app.

 

When making changes to the scopes for your app, to save the changes you'll need to click the "Submit" button in the bar at the bottom of the page. (Note that the bottom bar may be obscured by a cookie banner, if you haven't dismissed it yet, so be sure to do so first.)

 

Also, be aware that just adding a scope to your app via the App Console does not retroactively grant that scope to existing access tokens or refresh tokens. That being the case, to make any API calls that require that scope, you'll need to re-authorize the app to get a new access token (and refresh token, if being used) with that scope.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

That error indicates that you're using an access token/app that does not have the 'files.content.write' scope enabled.

 

To resolve that, you'll need to enable that 'files.content.write' scope for that particular app, by using the "Permissions" tab of the app's page on the App Console, while signed in to the account that owns that app.

 

When making changes to the scopes for your app, to save the changes you'll need to click the "Submit" button in the bar at the bottom of the page. (Note that the bottom bar may be obscured by a cookie banner, if you haven't dismissed it yet, so be sure to do so first.)

 

Also, be aware that just adding a scope to your app via the App Console does not retroactively grant that scope to existing access tokens or refresh tokens. That being the case, to make any API calls that require that scope, you'll need to re-authorize the app to get a new access token (and refresh token, if being used) with that scope.

notstrom
Helpful | Level 6
Go to solution
Thank you for your quick response. You gave me the best clue. 
All I had to do was create a new token using the “Generate” button in the “Settings” tab in
dropbox.com/developer.
When I do this process on the laptop, I can create a new directory via code on the laptop.
Now I can use my program on both machines.
Best regard
Peter
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    notstrom Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?