cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out 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: 

Access dropbox file - Authentication failed because the remote party has closed the transport stream

Access dropbox file - Authentication failed because the remote party has closed the transport stream

Lukag
Collaborator | Level 8

i'm new in this type of access.
I wrote this code but i have the error in objet to recover the list of files in dropbox.

Dim token As String
token = "sl.B6........."
Dim _command As String
_command = "https://api.dropboxapi.com/2/files/list_folder"

Dim Request As HttpWebRequest
Request = HttpWebRequest.Create(_command)

Request.Method = "GET"
Request.KeepAlive = True
Request.ContentType = "application/json"
Request.UserAgent = "Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36"
Request.AllowAutoRedirect = True
Request.Headers.Add("Authorization", "Bearer " & token)

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

Dim Response As HttpWebResponse = Request.GetResponse()

32 Replies 32

Здравко
Legendary | Level 20

The endpoint for folder listing is RPC call style endpoint. RPC on Dropbox uses POST request and it's mandatory 'path' to be passed in JSON style to the request body. Fix your code.

Good luck.

Greg-DB
Dropbox Staff

[Cross-linking for reference: https://stackoverflow.com/questions/78875640/access-dropbox-file-the-remote-server-returned-an-error... ]

 

Здравко is correct; be sure to refer to the documentation for information on how to properly construct these requests.

Lukag
Collaborator | Level 8

Thank you.

It's first time that i use this tools.

I changed the Metod in POST and insered the path ( looking other example ) but i have always error 401 not autorized.

this is new cod  : 

 

Dim _command As String
_command = "https://api.dropboxapi.com/2/files/list_folder"

Dim Request As HttpWebRequest
Request = HttpWebRequest.Create(_command)
Request.Method = "POST"
Request.KeepAlive = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
Request.ContentType = "application/json" ' application/x-www-form-urlencoded"
Request.UserAgent = "Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36"
ServicePointManager.SecurityProtocol = CType(48, SecurityProtocolType) Or CType(192, SecurityProtocolType) Or CType(768, SecurityProtocolType) Or CType(3072, SecurityProtocolType)
Request.AllowAutoRedirect = True

Request.Headers.Add("Authorization", "Bearer " & token)


Dim payloadLiteral = "{""Path"": ""/files/list_folder""}"

Dim payload = Encoding.UTF8.GetBytes(payloadLiteral)
Request.ContentLength = payload.Length

Using dataStream = Request.GetRequestStream()
dataStream.Write(payload, 0, payload.Length)
End Using

Try
 Using response = CType(Request.GetResponse(), HttpWebResponse)
    Using reader = New IO.StreamReader(response.GetResponseStream())
        'Return reader.ReadToEnd()
    End Using
 End Using
Catch ex As WebException
Using response = CType(ex.Response, HttpWebResponse)
    Using reader = New IO.StreamReader(response.GetResponseStream())
      Throw New Exception(reader.ReadToEnd())
    End Using
End Using
Catch ex As Exception
Throw
End Try

 

Здравко
Legendary | Level 20

Are you sure the access token you're using is actual one and not expired? 🧐

Also, post the received result (either error or success) so it be clear what's going on exactly..

Lukag
Collaborator | Level 8

I have generate a new token and insered in my web app.

Additional information: Error in call to API function "files/list_folder": request body: unknown field 'Path'

 

Здравко
Legendary | Level 20

Yes, of course. it's case sensitive! Also, make sure the path is valid... you may start with just empty string - it's always valid.

Lukag
Collaborator | Level 8

Perfect, it looks right.

Just a question : i had my token , generate 1 or 2 days ago and that didn't work.

If i go in App console i didn't see it and o i generate again.

How is valid a token ? 

should i generate a new one every time i use my web app ? 

 

Здравко
Legendary | Level 20

@Lukag wrote:

...

How is valid a token ? 

should i generate a new one every time i use my web app ? 


Access token is short lived, so you may use it for limited time - typically 4 hours or so. If you plan to rely on access token only then, Yes, you will need new every time you are using your application. There is alternative though. 😉 Take a look here for a possible way.

Hope this helps.

Need more support?
Who's talking

Top contributors to this post

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