string accessToken = "Token";
var request = (HttpWebRequest)WebRequest.Create("https://api.dropboxapi.com/2/files/list_folder");
request.Method = "Post";
request.Headers.Add("Authorization", "Bearer " + accessToken);
request.ContentType = "application/json";
Stream newStream = request.GetRequestStream();
var response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string responseString = sr.ReadToEnd();
I'm getting this error. How can i slove this ?
The remote server returned an error: (400) Bad Request.
I'm trying this url in postman
Header : Authorization:Bearer Token
This following error came . How can i solve this please help me
Error in call to API function "files/list_folder": This function requires its argument in the HTTP request body, but your request body is empty
@saravananct143 looking at your code above it seems like you are not adding any content to the body of your POST request.
To do this for HttpWebRequest you will need to encode the data, and then add some additional code to send that data after you make the call to GetRequestStream().
There is a good example of this in Microsoft's HttpWebRequest documentation found here:
Note the creation and encoding of the postData variable into a byte array, and then, later on, the writing of that data to the request stream after the call to GetRequestStream().
For your Dropbox API request, the postData content will be the JSON formatted parameters specified in the documentation for /list_folder that @Greg-DB referenced earlier in this thread.
Further, if you are using version 4.5 or newer of .NET, I would suggest looking at HttpClient vs HttpWebRequest as it provides a much simpler implementation for sending HTTP requests:
Hope that helps,
The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.Sound good? Let's get started.
For more info on available support options, see this article.
If you found the answer to your question, please 'like' the post to say thanks to the user!