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 404 Server remote no found

Error 404 Server remote no found

Lukag
Collaborator | Level 8
Go to solution

I have an expired token so to get a new one.

I try with this code but i have the error Error 404 Server remote no found.

 

I use https://api.dropbox.com and https://api.dropboxapi.com with the same result.

Dim _command As String
_command = "https://api.dropboxapi.com/oauth2/token "
_command += " -d grant_type=refresh_token "
_command += "-d refresh_token=" & _refresh_token
_command += "-d client_id=" & _App_key
_command += "-d client_secret=" & _App_secret
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

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

 

Thank you.

Luca

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20
Go to solution

@Lukag wrote:

I changed my code but i have an error 400 Bad request 

...


Hm..🤔 You didn't mention, but let me guess: the error message states - unsupported grant type or so. Right?

What grant type you're using EXACTLY? 🧐 Focus on "exactly"! Even one letter - more or less - may make the things wrong. 😉

 

PS: Print out what you're passing as body text and compare what has to be as we discussed in previous threads. Does it match?

View solution in original post

9 Replies 9

Здравко
Legendary | Level 20
Go to solution

It may be easier for you to execute curl, that you know how it works already, as shell command and read the StdOut that comes back. 🙋

Lukag
Collaborator | Level 8
Go to solution

sure but this is a call that i need and I would like to understand where I'm going wrong.

Здравко
Legendary | Level 20
Go to solution

@Lukag wrote:

... I would like to understand where I'm going wrong.


Let say...🤔, where did you see/conclude from, that the above is the way do what you want to do? 🙂 I'll stop here. You know the rest.

You can take a look an example like this one, where external command gets executed in other application. Can you do the same but with your working curl command and parse the received output instead of just forward to your application terminal? 😉

Lukag
Collaborator | Level 8
Go to solution

maybe I understood the problem. I try to continue with my method. ty.

( Is there the possibility for users to write directly to each other in the Dropbox community? ) 

DB-Des
Dropbox Engineer
Go to solution

Hi @Lukag,

 

The following lines of code are actually appending the parameters to the URL, hence why you are receiving a 404.

 

 

Dim _command As String _command = "https://api.dropboxapi.com/oauth2/token "
_command += " -d grant_type=refresh_token "
_command += "-d refresh_token=" & _refresh_token
_command += "-d client_id=" & _App_key
_command += "-d client_secret=" & _App_secret

 

 

 

Additionally, as a reminder, endpoint /oauth2/token accepts ContentType: application/x-www-form-urlencoded. From your example, it looks like you are using application/json.

 

We'd recommend re-writing the logic of your app to use the corresponding ContentType and to pass the parameters in the body of the POST request.

 

I hope you find this information helpful!

Lukag
Collaborator | Level 8
Go to solution

I changed my code but i have an error 400 Bad request 

(I try with api.dropboxapi.com and with api.dropbox.com , which one is the right one ? )
Dim _command As String
_command = "https://api.dropboxapi.com/oauth2/token "
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/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


Dim postbody As String =  "&grant_type=refresh_token "
postbody += "&refresh_token=" & _refresh_token
postbody += "&client_id=" & _App_key
postbody += "&client_secret=" & _App_secret

Dim payload = Encoding.UTF8.GetBytes(postbody)
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())
   _file = reader.ReadToEnd()
   End Using
End Using
Catch ex As WebException
   Using response = CType(ex.Response, HttpWebResponse) 
   Using reader = New IO.StreamReader(response.GetResponseStream())
   _errore = reader.ReadToEnd()
End Using
End Using
Catch ex As Exception
Throw
End Try

Здравко
Legendary | Level 20
Go to solution

@Lukag wrote:

I changed my code but i have an error 400 Bad request 

...


Hm..🤔 You didn't mention, but let me guess: the error message states - unsupported grant type or so. Right?

What grant type you're using EXACTLY? 🧐 Focus on "exactly"! Even one letter - more or less - may make the things wrong. 😉

 

PS: Print out what you're passing as body text and compare what has to be as we discussed in previous threads. Does it match?

Lukag
Collaborator | Level 8
Go to solution

the problem was that i put a space after refresh_token ...you can see  "&grant_type=refresh_token "

( i use https://api.dropboxapi.com/oauth2/token  and it works ) 

Thank you very much

Greg-DB
Dropbox Staff
Go to solution

Thanks for following up. I'm glad to hear you got that working. For reference, both api.dropbox.com and api.dropboxapi.com are acceptable for this.

Need more support?
Who's talking

Top contributors to this post

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