400 Bad Request UnityEngine.Debug:Log(Object) FBScript:DisplayUserName(IResult) (at Assets/Script/FBScript.cs:63) Facebook.Unity.c__Iterator1:MoveNext() (at Assets/FacebookSDK/SDK/Scripts/Utils/AsyncRequestString.cs:133)

void DisplayUserName(IResult result){
    Text UserName = DialogUserName.GetComponent<Text>();
    if (result.Error==null  ) {
        UserName.text = "Hi there," + result.ResultDictionary ["first_name"];
    } else {
        Debug.Log (result.Error);


As SamedTarıkÇETİN said,

400 Bad Request means "request is not valid", you can't get a valid response with an invalid request.

Thanks man.

Well, I hope you are following the general way to Login Facebook as described in this answer.

If you want to get User Name from Facebook then you can use Graph API in this way.

After login successfully, call Graph API for name as,

FB.API ("me?fields=name", HttpMethod.GET, GraphCallbackForName);

Then in GraphCallbackForName callback, retrieve name as,

void GraphCallbackForName (IGraphResult result)
    IDictionary<string,object> dict = result.ResultDictionary;
    string fbname = dict ["name"].ToString ();
    Debug.Log ("FB Name: " + fbname);
|improve this answer|||||
  • 1
    \$\begingroup\$ Although I respect the solution, you are wrong by saying "For 400 Bad Request you already got an answer". 400 Bad Request means "request is not valid", you can't get a valid response with an invalid request. \$\endgroup\$ – S. Tarık Çetin Mar 14 '16 at 14:00
  • \$\begingroup\$ @SamedTarıkÇETİN exactly man, I said you got answer, not you got right answer. I didn't even care about that. Anyways, you are right. \$\endgroup\$ – Hamza Hasan Mar 14 '16 at 14:03
  • \$\begingroup\$ @Chetan There is one thing that only you can do, that is marking this as answer :P \$\endgroup\$ – Hamza Hasan Mar 14 '16 at 14:14

From w3c.org:

400 Bad Request

The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

I assume you fetch the dictionary every frame, or so often. For fetching static information from websites, you shouldn't request so frequently.

And for a "username", it is enough to fetch at the Start method and store the info on a field.

So you don't have to fetch information again and again, you can just use the value of field.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.