First of all I would like to apologize but this is the first time I use these tools (HttpClient and SendAsync ) I'd like to download asynchronously a file ( video / image / text ) from dropbox by the call files/download. This is my code but when the excecution arrive in the line with SendAsync the program exit from the function. Is there an error? how can I find it?
Async Function Download_Async(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", _path_file) Dim _message = Await client.SendAsync(_Request) Dim res = Await _message.Content.ReadAsStringAsync() I installed last version of nuget package System.Net.Http 4.3.4. and i try to change in various mode the define of HttpRequestMessage and SendAsync but this is ( i think ) the correct way.
I changed the firsts line
Dim client As New HttpClient Dim _Request = New HttpRequestMessage(Http.HttpMethod.Post, "https://content.dropboxapi.com/2/files/download") Error is : "Object reference not set to an instance of an object"
NullReferenceException?clientor the_Requestcould benull. Could you please update the question with the entire stacktrace?