Unable to create Folder using v 2.0 API
sujit1779
Registered Users Posts: 46 Big grins
Hi,
This is Sujit from PicBackMan and as recommended we are moving our application to API 2.0 . I am trying to create a FOLDER using NODE and below is my code, and it is giving Authorization issue, I am adding authorization header in it. What am I doing wrong?
This is Sujit from PicBackMan and as recommended we are moving our application to API 2.0 . I am trying to create a FOLDER using NODE and below is my code, and it is giving Authorization issue, I am adding authorization header in it. What am I doing wrong?
Uri url = new Uri("http://api.smugmug.com/api/v2/node/nXXXX8"); var request = (HttpWebRequest)WebRequest.Create(url.ToString()); string postData = "{'Type': 'Album', 'Name': 'My Smug Album', 'UrlName': 'My - Smug - Album', 'Privacy': 'Public'}"; var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentLength = data.Length; request.Accept = "application/json"; request.ContentType = "application/json"; string str; string str2; OAuth.OAuthBase base2 = new OAuth.OAuthBase(); string timeStamp = base2.GenerateTimeStamp(); string nonce = base2.GenerateNonce(); base2.includeVersion = true; string str5 = base2.GenerateSignature(url, ConsumerKey, ConsumerSecret, authToken, authSecret, "POST", timeStamp, nonce, OAuth.OAuthBase.SignatureTypes.HMACSHA1, out str, out str2); request.Headers.Add("Authorization", "OAuth oauth_consumer_key=\"" + ConsumerKey + "\",oauth_token=\"" + authToken + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\"" + HttpUtility.UrlEncode(str5) + "\",oauth_timestamp=\"" + timeStamp + "\",oauth_nonce=\"" + nonce + "\", oauth_version=\"1.0a\""); using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
0
Comments
Thanks.