Digil
Digil

Reputation: 69

facebook_business retrieve leads by form id

I'm writing a python script to fetch the leads by form id as mentioned in [here][1] Sending a GET request to

curl -i -X GET "https://www.facebook.com/ads/lead_gen/export_csv/
    ?id=<FORM_ID>
    &type=form"

works and a correct number of leads(32 in my case) in the form are fetched. Now I'm trying to use the bulk read api by

curl -G \
  -d 'access_token=<ACCESS_TOKEN>' \
  -d 'fields=created_time,id,ad_id,form_id,field_data' \
  https://graph.facebook.com/v10.0/<FORM_ID>/leads

Here the problem is that it fetches only one lead, ie the one with is_organic True. Rest are ignored. I get the same results from Graph API Explorer too. I've given app permissions for

read_insights

pages_show_list

ads_management

ads_read

business_management

leads_retrieval

pages_read_engagement

pages_manage_metadata

pages_manage_ads

public_profile

for the user token.

I know there is data present in forms but I'm missing something. What am I doing wrong? Thanks in advance. [1]: https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving

Upvotes: 1

Views: 1201

Answers (1)

Digil
Digil

Reputation: 69

I got this. It was due to the lack of permissions for the access token. Get your app reviewed and accepted by facebook. You'll have to explain why you need all the permissions your app requires and shoot a video explaining the same to their review team. Once your app get approved by their team, you can access all the data from facebook. In my case I also shared the python code, and got accepted within a few hours.

Upvotes: 0

Related Questions