3

I am using Facebook Ad Api to create ads. How ever when i grant a user Administrator Role (1001) with the following api call:

https://graph.facebook.com/v2.5/<AD_ACCOUNT_ID>/users?role=1001&uid=xxxxx

it successfully creates the user, and when i get all the users using the following request:

https://graph.facebook.com/v2.5/<AD_ACCOUNT_ID>/users

it successfully returns the array as:

"{"data":[{"name":"firstname lastname","permissions":[1,2,3,4,5,7],"role":1001,"id":"101xxxxxxxxxx352"}}"

but when i try to create an Ad campaign or Adset with the newly added user the following exception is thrown:

[FacebookAds\Http\Exception\AuthorizationException]
(#272) This Ads API call requires the user to be admin of the application. User 16xxxxx351 not admin or developer for application 109xxxxxxxx0403.

And when i go to my app and assign the user with an Administrator or Developer Role, I can make requests successfully.

Why is facebook not allowing a user created with administrator role from the api not make api calls to its Ad Api ? And why does it allow when the user is granted Administrator/Developer role make requests ?

Paul Bain
  • 4,364
  • 1
  • 16
  • 30
Chamindar2002
  • 223
  • 3
  • 15
  • I found a similar question on stackoverflow, but it has not been answered [here](http://stackoverflow.com/questions/28429695/facebook-ads-api-request-fails-with-273-requires-user-to-be-admin) – Chamindar2002 Dec 01 '15 at 05:09

2 Answers2

0

This is because the objects you can promote are not based upon an adaccount but are based upon your user.

You can see the connection objects a user has access to by make the following request:

<API_VERSION>/act_<AD_ACCOUNT_ID>/connectionobjects?access_token=<ACCESS_TOKEN>

The documentation states:

this call returns the IDs of all objects for which the current session user is an administrator, and the IDs of apps for which the user is listed as a developer or advertiser.

Paul Bain
  • 4,364
  • 1
  • 16
  • 30
  • Thanks for the feedback Paul. I am getting an exception when i do the above request `{ "error": { "message": "(#10) You do not have sufficient permissions to perform this action", "type": "OAuthException", "code": 10, "fbtrace_id": "BtfLD4Ise1y" } }` ,how do i properly assign a valid user to manage ad campaigns for example role 1001 ? – Chamindar2002 Dec 03 '15 at 03:59
0

If you don't want to make additional administrators for your app, you can create system user in Facebook Business Manager, grant him administrator (or even advertiser) rights for Ad Account.

https://developers.facebook.com/docs/marketing-api/business-manager-api

And use his token to manage ads. In my case I used it to retrieve targeting of ads, to find where leads came to lead form from.

https://www.facebook.com/marketingdevelopers/videos/vb.606699326111137/883648801749520/

Charlie4fun
  • 197
  • 2
  • 16