1
votes

I am trying to create custom object using facebook SDK like this:

Bundle params = new Bundle();
params.putString("type", "android_themes:background");
params.putString("url", "http://samples.ogp.me/471503979602314");
params.putString("title", "Sample Background");
params.putString("description", "");

Request request = new Request(
    Session.getActiveSession(),
    "me/objects/android_themes:background",
    params,
    HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response

But I am keep getting this error:

{Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 2500, errorType: OAuthException, errorMessage: Cannot specify type in both the path and query parameter.}, isFromCache:false}

Any ideas what is this mean? And what will I get when I be able to do it right? I am not so sure... P.S Publishing actions on my predefined objects works fine, just this problem.

1
Ad said in the error the problem is that you duplicate the object type, first in with the type parameter and then in the requestPath. Look at this example and also at the other standard actions for a correct way of doing that. - 5agado
@5agado but this is for actions not for objects - Ilya Gazman
Every action in the Open Graph must have an object associated to it. I don't think that you can publish an object without a proper action. As said on the overview page the four elements are actor, app, action, object. - 5agado

1 Answers

2
votes

The object is a JSON-encoded version of an object, the sample code generated for you was incorrect. Also remove type from the parameter list.

The object: The object is a JSON-encoded version of an object. The types used here are the types used in the books.book type. You can also include any of the standard properties. Note that the type is not included in the call. This is because it's implied from the path that you used when you made the call. See properties for why there's a data element in the JSON.

It is used to create objects which can then be used to create actions. See Facebook developers