Hello all,
Please if anyone did work on UploadAttachment "http://mail.yahooapis.com/ya/upload"; please post a complete successfully httpWebRequest sample.
this is my code:
file.SaveAs(Server.MapPath("/Uploaded/yahoo/"+dt+"-"+file.FileName));
MemoryStream ms = new MemoryStream();
file.InputStream.CopyTo(ms);
byte[] datacontent = ms.ToArray();
ms.Dispose();
string base64filecontent = Convert.ToBase64String(datacontent);
HttpWebResponse response;
Stream stream;
Uri uri = new Uri("http://mail.yahooapis.com/ya/upload?uploadfile=" + Server.MapPath("/Uploaded/yahoo/" + dt + "-" + file.FileName) + "&output=json");
string oauth_token = yhModel.OAuth_AccessToken;
string oauth_secret = yhModel.OAuth_TokenSecret;
HttpWebRequest webrequest = yhModel.GetWebRequest(oauth_token, oauth_secret, uri, "POST");
webrequest.Method = "POST";
webrequest.ContentLength = file.ContentLength;
Stream ws = webrequest.GetRequestStream();
ws.Write(datacontent, 0, datacontent.Length);
ws.Flush();
ws.Close();
response = (HttpWebResponse)webrequest.GetResponse();
stream = response.GetResponseStream();Note: i have tried to put =>
webrequest.ContentLength = 0, and remove the
webrequest.GetRequestStream();
but with same error which is
000002b {"Response":{"cred":"uploadFileSizeError"}} 0
Please help