Hi,
I am trying to use REST to retrieve a file sharing link but I am receiving either error 401 or 403. The error I receive varies according to the tests that I try to run lol.
I have the following method:
static string HttpPost(string url, string[] paramName, string[] paramVal)
{
var req = WebRequest.Create(new Uri(url))
as HttpWebRequest;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.Accept = "*/*";
// Build a string with all the params, properly encoded.
// We assume that the arrays paramName and paramVal are
// of equal length:
var paramz = new StringBuilder();
for (int i = 0; i < paramName.Length; i++)
{
paramz.Append(paramName[i]);
paramz.Append("=");
paramz.Append(HttpUtility.UrlEncode(paramVal[i]));
paramz.Append("&");
}
// Encode the parameters as form data:
byte[] formData =
UTF8Encoding.UTF8.GetBytes(paramz.ToString());
req.ContentLength = formData.Length;
// Send the request:
using (var post = req.GetRequestStream())
{
post.Write(formData, 0, formData.Length);
}
// Pick up the response:
string result = null;
using (var resp = req.GetResponse()
as HttpWebResponse)
{
var reader =
new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();
}
return result;
}
I pass as parameter the following:
url: https://api.dropbox.com/1/shares/auto/path
parameters
values
In my first try, I have tried passing as parameters as parameter the following:
oauth_consumer_key, oauth_nonce, oauth_signature_method, oauth_timestamp, oauth_token, oauth_version, oauth_signature
As a result, I have received Error 403 Forbidden. so I assumed I was receiving this error because of authentication which is funny because I am passing through the parameters, so then I did the following:
included those parameters after the url just like the example below:
https://api-content.dropbox.com/1/shares/auto/PATH?oauth_consumer_key=XXX&oauth_nonce=XXX&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1434773930&oauth_token=XXX&oauth_version=1.0&oauth_signature=XXX
As a result I have received error 401 Unauthorized.
I am obtaining file URI through SharpBox, using the following:
var uri = dropBoxStorage.GetFileSystemObjectUrl(file.Name, folder);
Would anyone know why I am not able to retrieve that sharing link?