cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Running into an odd problem when using UploadAsync

Running into an odd problem when using UploadAsync

donaldp
Collaborator | Level 9

Hi,

 

    Same program as I've discussed before (.net running on UWP and Android) I'm having an issue when it runs on Android (works as expected on UWP. In fact I haven't even touched this particular code in months, but has only just stopped working on Android). In this case I've over-ridden the app settings with a hard-coded path so that it really is the exact same file in the exact same location on both devices. 😉

   Trying to get the metadata for the file I'm uploading, Visual Studio is saying that my "metadata" variable, which is the output of the operation, is null! It's an output variable, so it's taking the output of the operation and having that assigned to it. It starts out null, and then (hopefully) ends up not null. Normally only get Null exception for an input file, not an output file!

   I'm not getting any messages from Dropbox - errors or otherwise - so I can't be sure if UploadAsync is actually running or not. i.e. is VS throwing the exception at the start or the end of the operation? Is there a way to get UploadAsync to display some output either way so that I can see if it's executing? Or do you have any ideas on what's happenning here? I'm thinking it's not getting that far, cos if it ran and failed then the code should then go to the catch statement. See screenshot of code (VS is stopping at line 305, but only on Android, not UWP).
metadataError.jpg

6 Replies 6

Greg-DB
Dropbox Staff

The Dropbox SDK doesn't offer a way to enable more verbose output, such as for UploadAsync to offer more information about the operation. It's unclear exactly what's occurring here, or why you'd get a NullReferenceException on the variable being used as output, if that is what's happening. Can you print out the full stack trace for the exception? That may offer some insight.

donaldp
Collaborator | Level 9

Hi Greg,

   The call stack just shows that the method is being called and is at line 305. See screenshot.

MetadataCallstack.jpg

Greg-DB
Dropbox Staff

Thanks, looking at that line then, is it possible DxClient itself is null? The screenshot is cut off, but I presume there aren't any other variables referenced that I can't see. The Locals pane shows stream and commitInfo as defined, but DxClient isn't shown.

donaldp
Collaborator | Level 9

Hi Greg,

 

   DxClient is my global Dropbox client, and definitely not null, but in running my program again to get a screenshot of that for you I did find that it's not authorised! Not sure how that came to be, but I'll chase that down now, as that is probably why I'm getting this message (though not sure why I'm not getting some kind of message to indicate that). Will let you know how it goes.

 

thanks,

  Donald.

 

donaldp
Collaborator | Level 9

Hi @Greg-DB 

 

   Just an update and a request...

 

   It did turn out that the issue was being unauthorised, so I've got a bunch of extra code in there now to deal with that scenario (some changes I'd made had meant I was hitting some code earlier than previously and thus running into unauthorised), so the problem is now solved from that point of view.

 

   As noted previously, I had absolutely no output from Dropbox though to indicate this, just the "null reference" message for my output variable. My Dropbox client wasn't null, but it also wasn't authorised (hence no output to my variable). Can we please add an unauthorised exception, to make it clearer to devs what is happenning? Or even better a way to get more verbose output from the client, because I had nothing at all from it to indicate that things weren't right.

 

thanks,

  Donald.

Greg-DB
Dropbox Staff

The .NET SDK does raise an AuthException for authorization issues, such as for AuthError.IsInvalidAccessToken. It's unclear why you wouldn't have received that though; it seems to be working as expected for me. Can you clarify what you mean exactly when you say your "client wasn't null, but it also wasn't authorised"? Did it have a revoked access token, or something else? Feel free to share the relevant steps/code for getting your DxClient into that state so we can look into it. Thanks!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    donaldp Collaborator | Level 9
What do Dropbox user levels mean?