0

add buddy HTTP 500

need help... i got an Internal Server Error (500) for buddy request in c#
here my code...

Uri ar11 = new Uri("http://rcore1.messenger.yahooapis.com/v1/buddyrequest/yahoo/user_yahoo_id");

StringBuilder sb1 = new StringBuilder(ar11.ToString());
sb1.AppendFormat("?oauth_callback={0}&", "oob");
sb1.AppendFormat("oauth_consumer_key={0}&", OAuthConsumerKeyKey);
sb1.AppendFormat("oauth_nonce={0}&", OAuthNonceKey);
sb1.AppendFormat("oauth_timestamp={0}&", OAuthTimestampKey);
sb1.AppendFormat("oauth_token={0}&", g_oauth_token);
sb1.AppendFormat("oauth_token_secret={0}&", g_oauth_token_secret);
sb1.AppendFormat("oauth_signature_method={0}&", "PLAINTEXT");
sb1.AppendFormat("oauth_version={0}&", "1.0");
sb1.AppendFormat("sid={0}&", g_session_id);
sb1.AppendFormat("oauth_signature={0}", sig.ToString());

HttpWebRequest request3 = System.Net.WebRequest.Create(sb1.ToString()) as System.Net.HttpWebRequest;

string postData = "{\"authReason\":\"" + msg + "\"}";
request3.Method = "POST";
request3.ContentLength = postData.Length;
request3.ContentType = "application/json;charset=utf-8";

Stream dataStream = request3.GetRequestStream();
UTF8Encoding encoder = new UTF8Encoding();
byte[] bytes = encoder.GetBytes(postData);
dataStream.Write(bytes, 0, bytes.Length);



thanksss

by
3 Replies
  • QUOTE (Johan Kk @ Jun 20 2011, 08:25 PM) <{POST_SNAPBACK}>
    need help... i got an Internal Server Error (500) for buddy request in c#
    here my code...

    Uri ar11 = new Uri("http://rcore1.messenger.yahooapis.com/v1/buddyrequest/yahoo/user_yahoo_id");

    StringBuilder sb1 = new StringBuilder(ar11.ToString());
    sb1.AppendFormat("?oauth_callback={0}&", "oob");
    sb1.AppendFormat("oauth_consumer_key={0}&", OAuthConsumerKeyKey);
    sb1.AppendFormat("oauth_nonce={0}&", OAuthNonceKey);
    sb1.AppendFormat("oauth_timestamp={0}&", OAuthTimestampKey);
    sb1.AppendFormat("oauth_token={0}&", g_oauth_token);
    sb1.AppendFormat("oauth_token_secret={0}&", g_oauth_token_secret);
    sb1.AppendFormat("oauth_signature_method={0}&", "PLAINTEXT");
    sb1.AppendFormat("oauth_version={0}&", "1.0");
    sb1.AppendFormat("sid={0}&", g_session_id);
    sb1.AppendFormat("oauth_signature={0}", sig.ToString());

    HttpWebRequest request3 = System.Net.WebRequest.Create(sb1.ToString()) as System.Net.HttpWebRequest;

    string postData = "{\"authReason\":\"" + msg + "\"}";
    request3.Method = "POST";
    request3.ContentLength = postData.Length;
    request3.ContentType = "application/json;charset=utf-8";

    Stream dataStream = request3.GetRequestStream();
    UTF8Encoding encoder = new UTF8Encoding();
    byte[] bytes = encoder.GetBytes(postData);
    dataStream.Write(bytes, 0, bytes.Length);



    thanksss


    Hi, first you should target the appropriate URL:
    <server>/v1/group/{groupname}/contact/{network}/{contactId}
    ie:
    http://rcore1.messenger.yahooapis.com/v1/g.../yahoo/{{USER}}

    Hope it helps,
    Cheers,

    Thomas
    0
  • QUOTE (mf_tomd @ Jun 21 2011, 01:14 AM) <{POST_SNAPBACK}>
    Hi, first you should target the appropriate URL:
    <server>/v1/group/{groupname}/contact/{network}/{contactId}
    ie:
    http://rcore1.messenger.yahooapis.com/v1/g.../yahoo/{{USER}}

    Hope it helps,
    Cheers,

    Thomas



    now i got a ERROR 405 : Method Not allowed , using the url that such as your suggest. any idea?
    Thanks
    0
  • QUOTE (Johan Kk @ Jun 21 2011, 10:02 PM) <{POST_SNAPBACK}>
    now i got a ERROR 405 : Method Not allowed , using the url that such as your suggest. any idea?
    Thanks


    This is my function (working) to generate the URL to go against in order to add a contact:


    sGroupName = System.Web.HttpUtility.UrlEncode(sGroupName);
    string sUrl = "http://rcore1.messenger.yahooapis.com/v1/group/{{GROUP}}/contact/yahoo/{{USER}}";
    sUrl = sUrl.Replace("{{GROUP}}", sGroupName);
    sUrl = sUrl.Replace("{{USER}}", sYahooId);

    string request = string.Format("{0}?oauth_consumer_key={1}&oauth_nonce={2}&oauth_signature_method=PLAINTEXT&oauth_signature={3}%26{4}&oauth_timestamp={5}&oauth_token={6}&oauth_version=1.0&sid={7}", sUrl, sConsumerKey, Guid.NewGuid().ToString(), sConsumerSecretKey, oUser.GetOAuthSecretToken(), GetDateTimeNowEpoch(), oUser.GetOAuthToken(), oUser.GetLogginResponse().sessionId);

    And for the JSON, it's really weird that you have "authReason" ? Where did you find that? :oThomas
    0

Recent Posts

in Messenger IM SDK