How to create a facebook ad inside the sandbox via api? - facebook

I want to create a sandbox facebook ad.
I managed to create a Campaign and an AdSet but when I try to create an AdCreative or an Ad I get following exception:
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_subcode": 1885183,
"is_transient": false,
"error_user_title": "Article of the ad was created with an app in development mode",
"error_user_msg": "The advertisement was created by an app in development mode. It must be public to create this ad.",
"fbtrace_id": "123456789"
}
}
Does this mean its impossible to create even sandbox-ads as long as the app is in dev mode (not reviewd)?
If yes whats the point of the sandbox?
I followed this tutorial using Postman and curl step by step and everything worked until 4. Create Ad Creative. : https://github.com/keboola/ex-facebook-graph-api/wiki/Sandbox-Ad-Account-Testing-Environment

It will be better to post this question over the project issues
https://github.com/keboola/ex-facebook-graph-api/issues

Unfortunately this is a known issue on Facebook and it's not possible to create AdCreative for app in dev mode.
What I did is: I made a screencast for the possible part and make it possible for the reviewer to get access to the website to test it himself, this is also confusing, since there is no user interface where to check the created ad in sandbox, I created new facebook account, add it as a tester to my app, and send app for review explaining why ad can't be created, it was rejected the first time but I requested again and it got approved

Related

Facebook Graph API not working with comments?

I created a page and an app with a Facebook Developer account.
In the Explorer Tool, I can retrieve a list of posts with this query without any issues:
104801368572889/feed?fields=message,attachments&access_token=[token]
However, not so lucky when I try to retrieve the comments associated to a post with this query:
104801368572889_105680201818339/comments?access_token=[token]
That's the error I get:
{
"error": {
"message": "(#200) Missing Permissions",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "AOmx5mNZC9xUFysAWp4oX3s"
}
}
It sounds like this means I don't have permissions. I tried to add all the possible permissions in the Explorer Tool (included the pages_read_engagement that is probably the one required for this API call). However, this doesn't seem to work. I also tried to add permissions in the app from the Developer Dashboard, but this brings me into a long process of information requests and reviews by Facebook. I don't want to go through this process as I'm just doing development at the moment. Isn't there something as a sandbox or development mode, where I can set the permissions that I want?

Can't query instagram user with Graph API

Things were working find until yesterday. I'm developing a simple Instagram app, I made a basic login flow. Now, when I try to log in for the app with a business facebook account I get a message "You don't have any Instagram Business Accounts linked to a Page.", which is funny, because in business account manager, in "Instagram Accounts" tab, I have my business instagram account listed; trying to remove it gives me a message: "This Instagram Account can't be removed because it's already linked to an Instagram business profile.". Great, seems like it SHOULD be working. It isn't but, the second part follows.
I generated an access token for that instagram account for Instagram Basic Display API, queried node https://graph.instagram.com/me, I got my account ID in response. Now, I tried to query the user using Graph API - https://graph.facebook.com/17841431928202825 - but in response I get:
{
"error": {
"message": "Unsupported get request. Object with ID '17841431928202825' 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",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "AwbBT4_pYZjEg5HbG1UHYPi"
}
}
For this I'm using an access token generated for the facebook account.
Do you have any idea why the hell it can't see my account both querying the API and from Business manager?

Facebook - custom audience ToS for sandbox account

Im trying to create custom audience using API. With the live ad account this works, but with sandbox account i get the below error:
{
"error": {
"message": "Permissions error",
"type": "OAuthException",
"code": 200,
"error_subcode": 1870034,
"is_transient": false,
"error_user_title": "Custom Audience Terms Not Accepted",
"error_user_msg": "You'll need to agree to the Custom Audience terms before you can create or edit an audience of CUSTOM type. To accept, go to https://www.facebook.com/ads/manage/customaudiences/tos/?act=************.",
"fbtrace_id": "********"
}
}
When i goto the URL provided, it tells me:
The link you followed may have expired, or the page may only be visible to an audience you're not in.
I have accepted ToS in marketing app tools as well.
I have added system user to the business, made system user as app admin for the app.
When i check for accepted ToS, i get this:
{
"tos_accepted": {
"web_custom_audience_tos": 1
},
"id": "act_***********"
}
I have looked at following answers, but still getting error:
https://stackoverflow.com/a/42766604/5690875
Am I missing any step?
I am having the same issue. So far I couldn't manage to get those Custom Audience ToS properly accepted by the sandbox Ad Account.
What did work for me was to create some dummy accounts and apps so I could use the API and test my code.
For now I did open a bug https://developers.facebook.com/support/bugs/370563156815064 and if there is any update I will update my answer here too.
Also there is another very similar bug already open https://developers.facebook.com/support/bugs/229033267958911. In the comments Felix(the guy who opened the bug) says that he managed to login with the sandbox Ad Account and accept the terms. I do not know how would you login with a sandbox Ad Account, but I did not look into it either.

Facebook sdk error: "Application does not have permission for this action"

I'm trying to use facebook java sdk to create ads. I'm able to create AdCampaign and AdSet, but when I'm trying to create AdCreative, it returns with error:
{
"error": {
"message": "Application does not have permission for this action",
"type": "OAuthException",
"code": 10,
"error_subcode": 1341012,
"is_transient": false,
"error_user_title": "No permission to access this profile",
"error_user_msg": "You don't have required permission to access this profile",
"fbtrace_id": "Gvc9OPtfxrb"
}
}
To create APIContext, I'm using Access Token, generated from "System User" section under Business settings and App Secret from application settings.
To create AdAccount, I'm using Ad Account Id.
I guess I miss some Id or Token, because I can go Ads Manager and do everything I need from ui, so looks like I have enough permissions.
Could you help me to figure out what I'm doing wrong?
We faced a similar issue wherein we were able to create campaigns and adsets using the API token generated for the ad account but not able to publish ads.
The problem was that the ad account for which the API token was generated had access to pages and the ad manager account but in addition to that we will have to give the user access to the page & ad account and apps. Because FB assumes that some user is running the code and not the ad account and hence users should be given access.
Just go to users -> People and add assets and the respective page, ad accounts and apps and run the code.

Accessing Facebook Ads API request error 270

I have a whitelisted Facebook App that is out of sandbox mode and has been approved for the Ads API, but I am receiving the following error when trying to make requests to the Ads API.
{
"error": {
"message": "(#270) This Ads API request is not allowed for apps with only developer access",
"type": "OAuthException",
"code": 270
}
}
This occurs when using adgroupstats, adcampaignstats, and reportstats requests, etc. The adaccounts request does return my account information though. My dashboard does read "This app is public and available to all users", as I needed to get out of sandbox mode in order for my app to be whitelisted.
Is there another setting that I have missed in order to gain access to the Ads API calls that I need?
Answer:
This is most likely due to your dev/admin accounts of the app not being set as "Admins" in facebook's ad manager. Let me know if this solves this issue for you.
Old response:
I am running into the same issue. Can not run api calls against reportstats even though the user that the app/ad account belongs too was an admin, i change that user to a developer and its still happening.
I opened a bug report for this: https://developers.facebook.com/bugs/786289188058999