cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
If you’ve changed your email address, now's the perfect time to update it on your Dropbox account and we’re here to help! Learn more here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Need Help ON API HTTP POST

Need Help ON API HTTP POST

athnetix
Explorer | Level 3
Go to solution

Brand new user to DropBox API and have run into a issue trying to run an API.

 

I am able to get thru the Auth2 verification OK in my code and now want to just run a simple API.

So I tried with the API:  https://api.dropboxapi.com/2/file_requests/count

I constructed a HTTP POST request as follows:

 

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

Dim hwrequest As Net.HttpWebRequest = Net.HttpWebRequest.Create("https://api.dropboxapi.com/2/file_requests/count")
hwrequest.UserAgent = "http_requester/0.1"
hwrequest.Timeout = 60000
hwrequest.Headers.Add(stoken) ----stoken is in JSON format
hwrequest.Method = "POST"
hwrequest.ContentType = "application/json"

Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse()
If hwresponse.StatusCode = Net.HttpStatusCode.OK Then
Dim responseStream1 As IO.StreamReader = _
New IO.StreamReader(hwresponse.GetResponseStream())
Dim responseData1 = responseStream1.ReadToEnd()
End If

 

When I run this I get an error: Specified value has invalid HTTP Header characters. Parameter name: name

 

Now looking at the documenation it seems that the Header I added needs to be in a json format, which I did.

 

Question if I added the authorization as a header is it true it needs to be in JSON format. 

 

Any help wiould be great.

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

No, the "Authorization" header value should not be JSON. It should be plain text of the format: 

 

 

Bearer ACCESS_TOKEN_HERE

 

 

You can find an example of what a call to /2/file_requests/count would look like using curl in the documentation

 

For reference, /2/file_requests/count is an "RPC" style endpoint, so any API call parameters (separate from the Authorization) it takes would be expected as JSON in the request body, not a header. Note that /2/file_requests/count in particular doesn't take any API call parameters anyway though, so you don't need to supply a request body when calling it.

 

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

No, the "Authorization" header value should not be JSON. It should be plain text of the format: 

 

 

Bearer ACCESS_TOKEN_HERE

 

 

You can find an example of what a call to /2/file_requests/count would look like using curl in the documentation

 

For reference, /2/file_requests/count is an "RPC" style endpoint, so any API call parameters (separate from the Authorization) it takes would be expected as JSON in the request body, not a header. Note that /2/file_requests/count in particular doesn't take any API call parameters anyway though, so you don't need to supply a request body when calling it.

 

athnetix
Explorer | Level 3
Go to solution

Thanks so much for your help on this.. I did get it working oK.

 

 

Need more support?