1
votes

Afternoon all, 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 snippit 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, Nullable1 clientModified, Boolean mute) at Dropbox.Api.Files.Routes.FilesUserRoutes.UploadAsync(String path, WriteMode mode, Boolean autorename, Nullable1 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

1 Answers

5
votes

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

"TestFolder/test.txt"

you should have something like:

"/TestFolder/test.txt"