4

I'm trying to list all of my draft campaigns using the Facebook marketing API. By default, it seems, only non-draft (published?) campaigns are listed when calling

curl -i -X GET \
 "https://graph.facebook.com/v12.0/act_12345/campaigns?fields=id,name&access_token=<mytoken>"

When looking at the code of the facebook-python-business-sdk, there are multiple references to unpublished content type, which makes me think that there should be a way to list all unpublished campaigns. So my question is how can I list all campaigns, published and unpublished?

I know this question is a duplicate (see here, here, and here) but I'm asking it again since it has not been answered and I'd like to put out a bounty for a helpful response.

Oleksii Tambovtsev
  • 2,666
  • 1
  • 3
  • 21
Tea Tree
  • 882
  • 11
  • 26

1 Answers1

2

I believe the only way to get draft campaigns is below:

  1. You should get all addrafts. On my account I have only 1 addraft that contains all draft campaigns, but maybe you can have more. URL for getting addrafts:

https://graph.facebook.com/v12.0/act_<ad_account_id>/addrafts?access_token=<access_token>&fields=name,ad_object_id,id

  1. Now you can get addraft_fragments. You can see all draft fragments of your ad_account (campaigns, adsets, ads), but you can easily find here what you want. URL for getting addraft_fragments:

https://graph.facebook.com/v12.0/<addraft_id>/addraft_fragments?access_token=<access_token>&fields=name,id,ad_object_id,ad_object_type,budget,ad_object_name,values

Oleksii Tambovtsev
  • 2,666
  • 1
  • 3
  • 21
  • When running the first call, I receive ```"message": "(#100) Tried accessing nonexisting field (addrafts) on node type (AdAccount)",``` – Tea Tree Dec 02 '21 at 18:41
  • @TeaTree what type of access_token do you use? I suppose you use access_token of developer application, this token doesn't have needed permissions. But user access_token used on Facebook Ads Manager user interfaces have this permissions. – Oleksii Tambovtsev Dec 02 '21 at 20:28
  • Interesting, I was under the impression that I would always have to create a Facebook App in order to use the Marketing API. How do I get a Ads Manager access_token? – Tea Tree Dec 03 '21 at 01:35
  • There is no documented way to get this token. The only way is to get it from page source code at Facebook UI, for example at Ads Manager. – Oleksii Tambovtsev Dec 03 '21 at 11:08