cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Musicians, convert your MuseScore files to PDF to play music on the go! Learn 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: 

Error reading file async

Error reading file async

Lukag
Collaborator | Level 8

I had a problem to download a file ( an Image ) and someone recommended to me to do asynchronously.

I changed my code so : 

 Async Function _take_file(ByVal _file As String) As Task

....

Dim client As HttpClient = New HttpClient()

Dim _Request As HttpRequestMessage = New HttpRequestMessage(HttpMethod.Post, "https://content.dropboxapi.com/2/files/download")
_Request.Headers.Add("Authorization", "Bearer " + _token)
_Request.Headers.Add("Dropbox-API-Arg", _parametro)

Dim _response As HttpResponseMessage = Await client.SendAsync(_Request)

Dim _responseStream As Stream = Await _response.Content.ReadAsStreamAsync()
Dim myStreamReader As New StreamReader(_responseStream)

 

I have an error on the last line : 

System.NullReferenceException was unhandled
Message: An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll

11 Replies 11

Greg-DB
Dropbox Staff

I see you're getting a System.NullReferenceException. As Здравко said, that's not an error from the Dropbox API itself. You can find Microsoft's documentation for that exception here though.

Lukag
Collaborator | Level 8

ok i understand but the error is in : Dim myStreamReader As New StreamReader(_responseStream)

and i thought that was connected to the call  https://content.dropboxapi.com/2/files/download

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Lukag Collaborator | Level 8
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?