Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graph Request Error 500

My app uses Facebook Login Button of facebook-android-sdk. It was working until last days, now on a graph request on a page's feed

Bundle parameters = new Bundle();
parameters.putString("fields", "id,icon,created_time,name,caption,description,message,link,full_picture,shares");
parameters.putString("limit", "50");
parameters.putString("locale", mLocale);
String pathPosts = path + "/posts";
GraphRequest request = new GraphRequest(
        AccessToken.getCurrentAccessToken(), pathPosts, parameters, HttpMethod.GET,
        new GraphRequest.Callback() {
            @Override
            public void onCompleted(
                GraphResponse response) {
                mResponse = response;
                }
        });
request.executeAndWait();

I get the OAuthException error

{Response: responseCode: 500, graphObject: null, error: {HttpStatus: 500, errorCode: 1, errorType: OAuthException, errorMessage: An unknown error has occurred.}}

UPDATE Found that with limit lower-equal than 33 it works without errors

parameters.putString("limit", "33");

For another page's feed the limit must be lower-equal than 7 to work without errors

parameters.putString("limit", "7");

Question: what is now the rule for the limit in a graph api request for page's feed?

like image 854
GPack Avatar asked Feb 23 '17 16:02

GPack


1 Answers

Facebook Graph API has also got a Debug Mode. You need to pass an extra parameter debug=all in the REST API. It will give you the reason for the issue too in the response JSON if there is any issue.

Quoting Facebook documentation -

When Debug Mode is enabled, Graph API response may contain additional fields that explain potential issues with the request. To enable debug mode, use the debug query string parameter. For example:

GET graph.facebook.com /v2.3/me/friends access_token=...& debug=all

In your code, try changing this

String pathPosts = path + "/posts";

to this

String pathPosts = path + "/posts&debug=all";

Or

Add and an extra parameter "debug" "all" in your Bundle

and check what debug message you got

For more info on handling errors and debugging Graph API, see here - https://developers.facebook.com/docs/graph-api/using-graph-api/#errors

like image 114
Asutosh Panda Avatar answered Nov 04 '22 14:11

Asutosh Panda