2

I'm new to trying to integrate with a third party API and it's turning out to be tedious. Let me first explain my goal: Create a file (a .txt file), and upload it to a single Dropbox account for a user to retrieve later. Before it gets to the upload process, the file is all set to go as a memorystream. I then try to use this simple code (for testing purposes) to upload to my account, which I have the key for. Here's a general snippet of usage:

public async Task<string> ReturnNewUploader(FileDetailObject fdo) {
var dbx = new DropboxClient("MY KEY");
fdo.DropboxClient = dbx;
var action = await fileUploader.UploadFileAsync(fdo);
...}

public async Task<string> UploadFileAsync(FileDetailObject fdo) {
var dropbox = await fdo.DropboxClient.Users.GetCurrentAccountAsync();
var req = await fdo.DropboxClient.Files.UploadAsync("TestFolder/test.txt"   WriteMode.Overwrite.Instance, body: fdo.MemStream); 

The above is where the exception is thrown:

Value should match pattern '\A(?:(/(.|[\r\n]))|(ns:[0-9]+(/.)?)|(id:.*))\z'
Parameter name: path
ParamName: path

StackTrace: at Dropbox.Api.Files.CommitInfo..ctor(String path, WriteMode mode, Boolean autorename, Nullable`1 clientModified, Boolean mute)
at Dropbox.Api.Files.Routes.FilesUserRoutes.UploadAsync(String path, WriteMode mode, Boolean autorename, Nullable`1 clientModified, Boolean mute, Stream body)
at appname.BusinessLogic.FTPer.d__3.MoveNext() in C:.........\appname\appname.BusinessLogic\FTPer.cs:line 78

I don't understand what's wrong with the path - it seems to match what they're expecting. The directory exists on the account. I've tried it without using a folder either and just passing a filename and I get the same error.

Thoughts? Also, if this can be implemented more cleanly I'm absolutely open to suggestions. Just know that this really cannot use a login prompt and has to write out to a single Dropbox account which we control.

1 Answer 1

9

Non-root file paths should start with '/', so instead of:

"TestFolder/test.txt"

you should have something like:

"/TestFolder/test.txt"

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Greg - I was actually just doing this and found that solved the problem. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.