Cannot convert invalid JSON String to Json Object

May 13, 2011 at 3:37 PM

Hi, Kayson,

I'm working to get the comments from a certain post, what I did is this:

Facebook_Graph_Toolkit.GraphApi.Post post = new Facebook_Graph_Toolkit.GraphApi.Post(PostID, Api.AccessToken);

IList<Facebook_Graph_Toolkit.GraphApi.Comment> comments = post.comments;

but the error comes from the first line of code. I checked that the PostID and AccessToken are all valid. what could have went wrong?

Coordinator
May 13, 2011 at 4:44 PM

The library cannot convert the string given by Facebook into a JsonObject. Either the string is in an incorrect format, or there's some special case which the library cannot handle.

If you would like to, you can email me the PostID and AccessToken so I can take a look at what exactly went wrong. Don't post your AccessToken here.

May 14, 2011 at 11:35 AM

Hi, Kayson, thanks for the reply through email regarding the error, however, I am still not quite sure where I did wrong, because that postID is what I get thorugh:

string PostID = Api.PostFeed("...");

so I ran the program again and immediate after the post, I checked on FB, and it's there, so I grab the PostID that's just stored in DB and went to this link:

https://graph.facebook.com/(the_post_ID_that_I_sent)

and it gives me "false"

I'm wondering if I did anything wrong or is there a step that I missed. thanks!

May 14, 2011 at 12:12 PM

I understand that it needs to retrieve the post with access token, but from what you said, if the post object doesn't exist, then why would it appear in FB on my wall? thanks for clearing this for me, much appreciated =)

Coordinator
May 15, 2011 at 6:27 PM

It looks like this is a bug with Facebook in your case.

May 16, 2011 at 2:30 AM

have been working on this the whole weekend, and finally figured out something:

in order to get the post, the permission "read_stream" has to be allowed, instead of just "publish_stream"

however, Kayson, I discovered another thing that you might be interested in.

I did a post through Api.PostComment("...") method, and indeed it posted to my wall (I checked on facebook right after I post), but when I use:

Facebook_Graph_Toolkit.GraphApi.Post post = new Facebook_Graph_Toolkit.GraphApi.Post("<post_ID>", Api.AccessToken);
IList<Facebook_Graph_Toolkit.GraphApi.Comment> comments = post.comments;

the comments will not show the latest comments that I just post. I thought that I didn't post it right, so I went and check against this:

https://graph.facebook.com/<post_id>/comments?access_token=<token>

and it does display the latest comments.

it seems like Post.Comments does not display the latest comments, perhaps it's an session issue? because 5 minutes later after I close the object and run the code again, the latest comments did show up.