vctlzac
vctlzac

Reputation: 847

User can't delete this request: Unknown error

I'm trying delete an request using the following code:

function deleteRequest(<request_id>_<user_id>) { 
    FB.api(<request_id>_<user_id>, 'delete', function(response) {
        console.log(response);
      });
    } 

But facebook returns the following error:

message: "(#2) User can't delete this request: Unknown error"

type: "OAuthException"

What is going on?

Upvotes: 2

Views: 694

Answers (3)

pmaruszczyk
pmaruszczyk

Reputation: 2155

If user is not active user is not the one who received this request you can also use application access token (APPID|APPSECRET), however use it ONLY(!) in backend (not in javascript!) because of security reasons.

Upvotes: 0

vctlzac
vctlzac

Reputation: 847

The problem was that I was passing the id of the User that generated the request, but the correct is pass user_id of the user that received request.

Upvotes: 0

Juicy Scripter
Juicy Scripter

Reputation: 25918

Since you removing request with JS-SDK and not providing access_token explicitly (which means access_token for current user is used) this may be related to couple of things:

  • Active user is not the one who received this request.
  • Active user isn't application user yet.

Things to do:

  • Ensure you authorized user before trying to remove request.
  • Check that FB.getAuthResponse().userID is the same as <user_id>

Upvotes: 2

Related Questions