Search code examples
facebook-graph-apifacebook-marketing-api

facebook marketing API Unable to create adset with targeting


need some help i'm trying to create an adset with cities in the targeting object but i'm getting an error

{
    "error": {
        "message": "Invalid parameter",
        "type": "OAuthException",
        "code": 100,
        "error_data": "{\"blame_field\":\"targeting\"}",
        "error_subcode": 1487756,
        "is_transient": false,
        "error_user_title": "Locations can't be used",
        "error_user_msg": "Some of your locations overlap. Try removing a location.",
        "fbtrace_id": "AApf6HmHZneXVFLD1U8BK-D"
    }
}

steps to reproduce 1- create a campaign

curl -X POST https://graph.facebook.com/$API_VERSION/$ACCOUNT_ID/campaigns -F 'name=My Campaign' \
   -F 'objective=OUTCOME_AWARENESS'\
   -F 'status=PAUSED' \
-F 'special_ad_categories=[]'\
   -F "access_token=$ACCESS_TOKEN"

then, create an adset for this campaign

curl -X POST https://graph.facebook.com/v21.0/$MY_META_ACCOUNT_ID/adsets \
  -F 'name=My Ad Set' \
  -F 'campaign_id=6680088172618' \
  -F 'daily_budget=1000' \
  -F 'targeting={"geo_locations":{"countries":["US"],"cities":[{"key":2427178}]}}' \
  -F "access_token=$MY_META_ACCESS_TOKEN" \
-F "billing_event=IMPRESSIONS"

Solution

  • Assuming that city you are attempting to target is within the US, you have overlapping locations (and hence the error message is correct). If you're targeting the whole of the US, you should remove the city. If you want to just target the one city, remove US.