5

I'm trying to use Facebook iOS SDK 3.5 for publishing an Open Graph action. My action is: take a photo, and photo has an additional required string property named filter.

I am creating my graph object (all values are valid and working):

NSMutableDictionary<FBOpenGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:@"tonerapp:photo"
                                                title:@"photo"
                                                image:imageData
                                                  url:nil
                                          description:title];

Then I add my filter:

object[@"tonerapp:filter"] = filterName;

I try to post the object, and I can confirm that my filter property is there (enabled FBSetting logging behavior for URL requests to show request data):

Body (w/o attachments): 
object: {"description":"","type":"tonerapp:photo",
"tonerapp:filter":"classic","data":{},
"fbsdk:create_object":true,
"image":{"url":"fbstaging:\/\/graph.facebook.com\/staging_resources\/MDExMDE1MjkzNzU1Njc3MDE0MjoxNTM4NzgwNjUy","user_generated":"true"},
"title":"photo"}

I can see my filter property there, but the response is this:

error =    {
        code = 100;
        message = "(#100) Object Missing a Required Value: 
Object at URL '' of type 'tonerapp:photo' is invalid because 
a required property 'tonerapp:filter' of type 'string' was not provided.";
        type = OAuthException;
    };

Well, it IS there. I tried all possible combinations such as:

object[@"data"] = @{@"tonerapp:filter": filterName}; //wrapping into the data object

object[@"data"] = @{@"filter": filterName}; //wrapping into data and removing namespace

object[@"toner:filter"] = filterName; //app name instead of namespace name

object[@"filter"] = filterName; //no namespace name at all

[object setObject:filterName forKey:@"tonerapp:filter"]; //setobject notation

[object setValue:filterName forKey:@"tonerapp:filter"]; //setvalue notation

[object setObject:filterName forKey:@"filter"]; //setobject AND without namespace...

and possibly more. I've tried everything, but the API always fails with the same error. I can verify the rest of the object is correct, if I go to my app in Facebook and set filter as optional instead of required, it posts successfully. Is it a bug/insufficient documentation with the Graph API, or am I so blind that I can't see something obvious here?

Thanks, Can.

Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
  • Did you solve this problem? (I have run in to a similar problem myself: http://stackoverflow.com/q/20376634/824515) – Magnus Dec 04 '13 at 14:31
  • from what I remember, (it's been a while and I forgot to answer my own question here back then) it was about the URL property. the error description was misleading. i've used `[FBGraphObject openGraphObjectForPostWithType:@"tonerapp:photo" title:title image:imageData url:@"http://tonerapp.info" description:desc];` and it's working. try putting a URL when posting. – Can Poyrazoğlu Dec 04 '13 at 17:24
  • @Magnus please tell me if it solves the problem so I can add an answer, perhaps you can add an answer directly under here. – Can Poyrazoğlu Dec 04 '13 at 17:25
  • Sorry, but adding a URL did not solve my problem (which is not completely identical to this one). However, one line in your original question may turn out useful for me: I had not noticed before that custom properties are supposed to be embedded in a "data" dictionary. That will not solve my problem directly, but it might be useful in a workaround that I'm investigating right now. Thanks for helping me understand that. – Magnus Dec 05 '13 at 08:50
  • I hope it works, waiting for catch-up.. – Can Poyrazoğlu Dec 05 '13 at 23:43

2 Answers2

4

just put them under "data"

object[@"data"][@"youcustomproperty"] = @"smth";
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
0

Be sure your filterName is URL encoded. I had the same kind of issue with the name of a movie which was also a custom action on the graph. Try just to post a manual value only a simple string and let us know.

Thibaut Rey
  • 318
  • 2
  • 5