I did get this to work and wanted to follow up with my
working code in case it helps someone down the road. The big change was to switch from using raw HTTPWebRequest
object and use the WebClient object instead.
What that worked I’m not sure but it does. I’m assuming it’s something the WebClient
sets in the request that I was not doing in the old code.
String filename = @"c:\temp\text.pdf";
FileInfo afile = new FileInfo(filename);
Uri uri = new Uri("http://mail.yahooapis.com/ya/upload?uploadfile=" + Path.GetFileName(afile.FullName) + "&output=xml");
OAuthBase oauth = new OAuthBase();
string nonce = oauth.GenerateNonce();
string timeStamp = oauth.GenerateTimeStamp();
string normalizedUrl;
string normalizedRequestParameters;
string sig = oauth.GenerateSignature(uri, ConsumerKey, ConsumerSecret, OAuthToken, OAuthTokenSecret, httpmethod, timeStamp, nonce, signaturetype, out normalizedUrl, out normalizedRequestParameters);
string authHeader "Authorization: OAuth " +
"realm=\"yahooapis.com\"" +
",oauth_consumer_key=\"" + ConsumerKey + "\"" +
",oauth_nonce=\"" + nonce + "\"" +
",oauth_signature_method=\"HMAC-SHA1\"" +
",oauth_timestamp=\"" + timeStamp + "\"" +
",oauth_token=\"" + OAuthToken + "\"" +
",oauth_version=\"1.0\"" +
",oauth_signature=\"" + HttpUtility.UrlEncode(sig) + "\"";
WebClient uploadClient = new WebClient();
uploadClient.Headers.Add(authHeader);
string response = new System.Text.ASCIIEncoding().GetString(uploadClient.UploadFile(uri, filename));
<process the result>