3

I'm trying to build an application that will help manage different ad accounts for different customers (multiple businesses, so it has to handle multiple ad accounts). I'm looking at the ads API documentation for ad account groups, and the examples aren't working in the graph API explorer. Things like GET requests to

https://graph.facebook.com/v2.4/<AD_ACCOUNT_GROUP_ID>/users

(from Facebook's documentation here) are returning the following error:

{
    "error": {
        "message": "(#275) Ad account cannot be determined for this request", 
        "type": "OAuthException", 
        "code": 275
    }
}

As best as I can tell, the documentation is incorrect - I think it can't tell the difference between an ad account ID and an ad group ID (I know this pattern is also used for things like managing custom audiences which is why I'm guessing it thinks it should be seeing an add account ID). Is there a better guide on updating ad account group membership via the API I can reference, or an endpoint I can substitute in for Facebook's official documentation?

Eric Hydrick
  • 3,467
  • 2
  • 28
  • 41

2 Answers2

2

First off please note at this time, you can still use v2.3 Facebook graph calls, prior versions have been deprecated by Facebook.

You will get this error. If you try older graph versions:

{
   "error": {
      "message": "(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version.",
      "type": "OAuthException",
      "code": 2635
   }
}

At the time of this writing you can use v2.3 calls and it still works.

Next I presume you want to know all the users, within accounts so the first thing to do is to get the list of accounts... Then iterate through each.. on an ad account basis.

Look up the api call to get a list of ad accounts, for a Facebook user id. You will need the ad_read permission on the token in order to get the list.

Your api call should then look like this to get the users on each account.
Notice I put act_ in front of the actual account id. This is required and tells Facebook you are dealing with an ad account.

https://graph.facebook.com/v2.3/act_999998730499999/users?access_token=CAZZZZZpCZBjEBAJmcyfqbcluGAJZCtqfv4kI6CtLC7JGHaJ7IO2ImGCfkQFZC9NXCAZC2CAbtEdQcWMYFpqsFAkgJVqNqjnKGQkMrukyl53WZBIdq7vofFYyxvaTJTsWVOQhWTrjNoox0QqRCt3vGaDsRGHLBFDxqKLfXOcDKfS1oppj1nDjKdPe2GHYrHirlBkhxWS95MNgW7ajZZZZZ

Note: I have added ZZZZZs and 9999s in places to disguise my actual account and token.

The token used must be the ad account holder's token for the app. The user must have authorized the app for the ad_read permission on this token creation for the call to work.

The result looks like this:

{
   "data": [
      {
         "name": "Joe Programmer",
         "permissions": [
            1,
            2,
            3,
            4,
            5,
            7
         ],
         "role": 1001,
         "id": "999995304499999"
      }
   ]
}
Damon Hogan
  • 552
  • 3
  • 14
  • Thanks, v.2.2 was current when I originally wrote the question, but I've gone back and changed it to v2.4, which is the most recent as of today (although that's likely to change in the next few months). – Eric Hydrick Jul 16 '15 at 13:06
  • You are welcome, I changed my post also to be more in line with your changes. – Damon Hogan Jul 16 '15 at 19:07
1

When using the development access of the Facebook Ads API, you need to specify which adaccounts you are going to use and you must own the adaccounts.

See the following guide: https://developers.facebook.com/docs/reference/ads-api/access#standard_accounts

Paul Bain
  • 4,364
  • 1
  • 16
  • 30
  • So I should be querying https://graph.facebook.com/v2.2//...what to see and update the members of an ad account group? – Eric Hydrick Nov 18 '14 at 15:30
  • I'm assuming your app is only on the basic level access to the Ads API which means you can only access accounts owned by developers of the app. You need to specify which ones before you make any requests to the API. Looking at facebook.com/ads/manage you should be able the find your accounts – Paul Bain Nov 19 '14 at 09:31
  • 1
    I get that part, and the ad account is owned by me. What I don't know is the API endpoint that can show me a list of users in an ad account group (which I created and own) as well as the endpoints that let me add/remove members. – Eric Hydrick Nov 19 '14 at 13:21