So I have been trying to create an app that uses the Facebook Ads API to get ad costs and stats. I have created an app and added my ad account ids to the app settings but still get the error:
"error":{"message":"(#274) The ad account is not enabled for usage in Ads API. Please add it in developer.facebook.com -> application -> settings -> advanced -> advertising accounts -> Ads API. Account XXXXXXXXXXXXX not enabled for application XXXXXXXXXXXXX.","type":"OAuthException","code":274}}
Any idear why it would still be giving me this error? Or how I can get through this step.
When using the Ads API in development mode, you need to specify the AdAccounts you are going to use in the developer console.
See the following guide for more details:
https://developers.facebook.com/docs/reference/ads-api/access#standard_accounts
Let me give you the workaround that helped for me . You have to go your app and in the added products tab on the left side panel click on Marketing API , click on tools, on the right side, select the permissions needed and get the token. Now use this token and pass it with the FB.api('POST'.. call along with the other parameters. You won't get the error anymore and if you check your advert you will have a new campaign or Adset whichever you are trying to create.
I was getting this #274 error and it started working after adding the Test Sandbox Ad Account's ID (under Marketing API > Tools) to the Ads API Account Configuration (under Settings > Advanced > Advertising Accounts). Prior to adding the Test Sandbox Ad Account's ID, I had only added my production Ad Account's ID, which didn't work for some reason.
Also when I was making test Graph API calls using Graph API Explorer, there's the Application select box in the top right. For some reason it was defaulting to "Graph API Explorer" instead of the name of my application. Whenever I selected the name of my application and generated a new user access token, I was able to make requests similar to the following:
//Get the Ad name associated with an AD_ID
https://graph.facebook.com/<API_VERSION>/<AD_ID>?fields=adset_id,campaign_id,name,account_id
//Get the Adset name associated with an ADSET_ID
https://graph.facebook.com/<API_VERSION>/<ADSET_ID>?fields=account_id,name
//Get the Campaign name associated with a CAMPAIGN_ID
https://graph.facebook.com/<API_VERSION>/<CAMPAIGN_ID>?fields=account_id,name
Related
So, I've created a Webhook with Facebook for my Ads Leads. It is working - I'm receiving the Webhook with the RTUs.
The problem is when I call the api to retrieve the data associated with the form. I'm using the leadgen_id to call the api and I'm gettin:
Unsupported get request. Object with ID '' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api
The point is: when I test it here: https://developers.facebook.com/tools/lead-ads-testing the leadgen_id that is returned works with my API calls and I can access the form data that I need.
But when I try with the leadgen_id that I receive from users registering in my ads, it returns the error message.
Any idea of how I can solve this problem?
This sounds like missing 'scopes' on the access token you are using to make the Graph API call. Generally, for webhooks you need a few scopes, these are the ones I currently have on my webhook:
pages_manage_cta, pages_show_list, ads_management, leads_retrieval, pages_read_engagement, pages_manage_metadata, pages_read_user_content, pages_manage_ads, pages_manage_engagement, public_profile
You can use the Access Token Debugger tool to see the list of scopes on your access token (https://developers.facebook.com/tools/debug/accesstoken/)
Your Graph API access token might have expired. To setup a permanent access token follow the instructions on here: Long-lasting FB access-token for server to pull FB page info
I had this same problem. I was able to get this to work by giving my System User 'Manage Page' access and 'Leads Access' in Business Manager.
Add your System User to the Page with 'Manage Page' access.
Business Manager > Business Settings > Accounts > Pages, and select the Page you are working with from the list.
Click 'Add People,' select your System User, and toggle 'Manage Page' setting.
Add your System User to Leads Access.
Business Manager > Business Settings > Integrations > Leads Access, and select the Page you are working with from the list.
Click 'Add People, and select your System User.
I have troubles with adding my application to group for any test user.
I've created two test users and one of them has group and he is an admin there and I wrapped those users into test application.
I've added two permissions for groups (groups_access_member_info, publish_to_groups). In user settings I see my application but in group settings I can't add my application.
I need this because I would like to make request from facebook graph API.
Regards
In order to test the Groups API with an app in development mode, you need to be an admin of both the app and group. Test users don't count as admins of the app. Therefore, you'll need to use a real user account.
You don't have to add the app to the group, it is assumed that the app is added if you are the admin of the group.
Source: Facebook Platform Bug Report.
Additional information from another useful bug report:
to read group information (such as the /events edge on a group), the app needs to have the "Groups API" feature reviewed and approved,
and the app needs to be installed to the group. No additional
permissions are required on the access token.
to read information about the members of a group, the access token needs to have the groups_access_member_info permission granted during
login, and the app must have been approved for the "Groups API"
feature.
to publish to a group, the access token needs to have the publish_to_group permission granted, in addition to the app having the
"Groups API" feature
When testing this with your own groups in development mode, the Groups
API feature is assumed to be enabled, and when querying groups that
you manage, the API will behave as though the app is installed to your
group. Note that when querying group posts, you may only receive posts
made by yourself or other admins of the app.
When querying your group's events with your app in development mode,
the call worked as you didn't need any additional permissions on the
access token, and the API behaves as though your app is installed on
the group. This is similar to how this would work in production, as
the access token wouldn't need any additional permissions to be
granted during login.
To add your App to a Facebook Group in development mode so as to use the Groups API, you'll need to follow these steps
Ensure you are an Admin to both the App and the Facebook Group.
Create a Test version of your App from the main App, this enables you to use the Test App in a Facebook Group without needing to add the App to the Facebook Group or you'll get an OAuthException using the main App, see the docs.
Don't bother looking for the Test version of your App in the group app store as the Test App is bound automatically to any Facebook Group you are an Admin to.
Add the required permissions Groups API would use in a standard App see the docs like groups_access_member_info and publish_to_groups to get the most out of the Groups API.
Add Test Users to the App for them to see your posts made with the Test version of your App see the docs. This is not a must see the note below.
If you're testing with the Graph API Explorer change the Facebook App to the test version of your App to prevent an OAuthException.
Congrats! You can now use the Groups API with a Test version of your App to post to the Facebook Group you are an Admin to.
NOTE: Only your Admin account and the Test Users you add to the App can see the posts made with the Test version of your App, meaning mutations to Facebook are private to you an Admin and the Testers till you submit your App for review which you can read about here.
I have to integrate facebook custom audience apis with my application which handles users fb marketing.
After I log the user in to get the access token with all the relevant permissions like ads_read,ads_management and business_managment.
I am getting an error while trying to fetch the custom audiences for the client
type: OAuthException, code: 272, message: (#272) This Ads API call
requires the user to be admin of the application. User is not admin or
developer of this application., x-fb-trace-id: H6HzozvlbXp [HTTP 400]
Am I missing something in this or does facebook not allow for such a scenario or is it because the app is in development mode.
P.S I did try to add another admin https://www.facebook.com/ads/manager/ but no option for an app in the same.
While in development mode, you'll need the users to be admins of your app. Go to developers.facebook.com, select your App from the drop down on the top right. Click Roles on the menu on the right. Add the user as an admin. You may also need to add the ad account under Settings->Advanced->Authorized Account IDs.
I'm trying to query the Facebook Ads API with the Graph Api Explorer. I have two Ads Account connected to me (if i query /me/adaccounts/ I see both) one is my own and the other one I'm only admin on but not owner.
The Problem is with the one I'm not the owner. If I query my Adaccount with /act_<ACT_ID/stats I get a normal response with the stats back if I query the other account i get:
(#273) This Ads API call requires the user to be admin of the ad account. User <MY_USER_ID> not admin on ad account <ACT_ID>.",
I can see both Adaccounts normal in the Facebook Adsmanager.
What I have done to get the response is:
Create an Facebook App
Added the Adaccount under developer.facebook.com -> myApp -> settings -> advanced -> advertising accounts -> Ads API. Account
open GraphExplorer (https://developers.facebook.com/tools/explorer/)
select my created App
get AccessToken (ads_management, ads_read)
go to url me/adaccounts/
if i click on my adaccount it works if i click on the other i get the #273 error
I don't see what I'm doing wrong if someone could point me in the right direction I would be gratefull.
This may be due to your ad account is inactive or in a bad standing. Additionally if your access level of your ad account is in development level these types of errors may occur. please go through what's mentioned on the doc here
If you upgrade your account to basic or standard access levels this will be solved.
On development access level only end to end workflows are suggested. The following text is extracted from facebook documentation.
The development access level is designed for development purposes and is ideal for people who are just starting to build out their tool. In this level, you would not yet have customers using your tool. This level is open to all developers, and is intended to build out end-to-end workflows on the API before you get full permissions.
A similar issue has been reported on facebook bug reports. you can see the thread here
As #Igy stated it in a comment: "a user has to be the admin of both the ad account and the app (and not just an advertiser or have some other role on the ad account)".
There is 2 places to check that:
the app's roles page, https://developers.facebook.com/apps/[APP_ID]/roles/
the account's peoples page, https://business.facebook.com/settings/people/
Once the user is admin on both side, the API calls will be just fine.
Your business manager doesn't have admin rights. Please check the admin rights of the business manager and also add the app in your business manager to get the report stat(https://developers.facebook.com/docs/apps/business-manager#update-business).
I have facebook app with status Live and available to all users. When I login through this app on my site I get access_token for my facebook user. And with this access_token I can read with Ads API next methods (for my own ad campaigns):
/me/adaccounts
/act_<AD_ACCOUNT_ID>/agroups
But when someone else login on my site (and confirms all permissions) and I get his/her access_token I can't perform second api call. I get this error (#10) You do not have sufficient permissions to perform this action. But I can get account ids. So, first method works, second not. How to fix this?
P.S. Status of app in App details tab is Unapproved (lightblue circle).
P.P.S. After adding that user to app's developers all is ok with second method (adcampaigns).
Your app is most likely in development Tier for Ads API Access
https://developers.facebook.com/docs/reference/ads-api/access#limits
You need to apply for higher levels
Some time its happen when you reach the limit of Marketing API Access.
https://developers.facebook.com/docs/marketing-api/access
Suppose your application have basic Marketing API Access Levels (In Basic, further test, iterate, build an app with up to 25 external accounts.) and you reach limit of ad account. When your new ad account(s) will request Facebook Ads API access then facebook send you mention error response.
To check your ad account(s) and their limit
Facebook APP -> Settings -> Advance tab -> Advertising Accounts section -> Ads Api button
https://developers.facebook.com/apps/YOUR_APP_ID/settings/advanced/