1

I'm using C# with ASP.NET to make a game. I have a method to send post request and it's working fine in all request ( i.e. loging, scores ) exept when I try to give an earned achievement. In this case the server return Bad Request ( status - protocol error ) instead of (#3501) User has already earned .... This is a snipped from my method for sending

public static string SendRequest(string sUrl,
                             string sRequest,
                             string sMethod,
                             string sContentType = "application/x-www-form-urlencoded")
    {
      HttpWebRequest request;
        StreamReader reader;
        string sResponse;
        Encoding encoding = Encoding.UTF8; //I try different encoding without luck

        switch (sMethod.ToUpper())
        {
            case "POST":
            case "DELETE":
                //Initialize the WebRequest
                request = (HttpWebRequest)HttpWebRequest.Create(sUrl);
                request.AllowAutoRedirect = false; 
                request.Method = sMethod.ToUpper();
                request.ContentType = sContentType;
                request.ServicePoint.Expect100Continue = false;
                byte[] data = encoding.GetBytes(sRequest);
                request.ContentLength = data.Length;

                Stream stream =request.GetRequestStream();
                stream.Write( data, 0, data.Length );
                stream.Close();
                break;

....

So to give an new achievement I call this method: SendRequest( achievementURL, achievementParams, POST ); If I make second call Graph API return Bad Request instead of #3501 I can delete earned achievement without error ( SendRequest( achievementURL, achievementParams, DELETE );

I try to use different encodings without any luck. Can it be a bug in Graph API?! ( Graph API Explorer works fine )

Any help will be appreciateble

Juicy Scripter
  • 25,778
  • 6
  • 72
  • 93
Azzy Elvul
  • 1,403
  • 1
  • 12
  • 22

1 Answers1

1

"I try to use different encodings without any luck. Can it be a bug in Graph API?! ( Graph API Explorer works fine )"

Yeah, I encountered a similar issue where the C# SDK returned an error while the API Explorer worked fine. While I wait for a fix, I'm using the Javascript SDK to make the call that fails in C#.

You should log it as a bug at http://facebooksdk.codeplex.com/workitem/list/basic

DMCS
  • 31,720
  • 14
  • 71
  • 104