Vinay B R
Vinay B R

Reputation: 8421

"(453) A session key is required for calling this method" during facebook post delete

I am using c# facebook sdk. I am trying to delete a facebook post from my application(post was created from my application). I am getting a "(453) A session key is required for calling this method" error message.

I have granted offline_access,publish_stream responsibilities to my application.

string url = string.Concat( "https://graph.facebook.com/", postId );        
Facebook.FacebookClient queryClient = new FacebookClient( AppID, AppSecret );
url += "?method=delete&access_token=" + AppAccessToken;
IDictionary<string, object> parameters = new Dictionary<string, object>( );
parameters[ "access_token" ] = AppAccessToken;
object result = queryClient.Post( url, parameters );

I also tried queryClient.Delete but kept getting a (400) invalid webrequest error message.

Upvotes: 0

Views: 1754

Answers (2)

DMCS
DMCS

Reputation: 31870

For version 5.x, The valid syntax for deletion is (you don't need the querystring parameters)

to delete a comment, post, or photo that was created with the API:

object result = queryClient.Delete('ObjectId');

to remove a like

object result = queryClient.Delete('ObjectId/likes');

See: http://docs.csharpsdk.org/docs/making-synchronous-requests.html

Edit - 400 Bad Request

Try running a .Get(postid) first then run the .Delete().

Upvotes: 3

Igy
Igy

Reputation: 43816

You need to make that call with a user access token for a user currently logged in to your app (hence 'session' in the error message)

Upvotes: 0

Related Questions