facebook / facebook-python-business-sdk

Python SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
1.28k stars 631 forks source link

Unable to delete Ad Image using `remote_delete` #531

Closed aaronmak closed 5 years ago

aaronmak commented 5 years ago

As per the documentation at https://developers.facebook.com/docs/marketing-api/reference/ad-image/v3.1 , I've tried to delete an image using remote_delete. Currently I'm using facebook-business v3.1.5 .

Traceback (most recent call last):
  File "example.py", line 139, in <module>
    params={AdImage.Field.hash: image[AdImage.Field.hash]})
  File "/Users/aaron/90seconds_data/fb-business/.venv/lib/python3.6/site-packages/facebook_business/adobjects/abstractcrudobject.py", line 486, in remote_delete
    request.execute()
  File "/Users/aaron/90seconds_data/fb-business/.venv/lib/python3.6/site-packages/facebook_business/api.py", line 667, in execute
    api_version=self._api_version,
  File "/Users/aaron/90seconds_data/fb-business/.venv/lib/python3.6/site-packages/facebook_business/api.py", line 330, in call
    raise fb_response.error()
facebook_business.exceptions.FacebookRequestError:

Digging deeper, I realized that the url path is wrong. In the documentation, it mentioned /act_{ad_account_id}/adimages but the path returned is /. / is the default path in the AbstractCrudObject.

aaronmak commented 5 years ago

i found a method in the AdAccount object that allows me to delete images called delete_ad_images which is not in the official documentation

jingping2015 commented 5 years ago

Hi, if you want to delete Image, you should call remote_delete, if you want to dissociate an AdImage from an AdAccount, you should call AdAccount, delete_ad_images

aaronmak commented 5 years ago

That's what I thought but in my facebook business manager account, that's not what I see in both the sandbox account and a live account. And the api requires me to associate the image with an Ad Account.

In the documentation:

You can dissociate an AdImage from an AdAccount by making a DELETE request to /act_{ad_account_id}/adimages.

But in the API it sends a request to / which throws the above error

jingping2015 commented 5 years ago

It will be great you can use the debug mode https://github.com/facebook/facebook-python-business-sdk#debug to check what's the curl call is.

Since we want to handle bugs more efficiently, we've decided to close issue reporting in Github and move to our dedicated bug reporting channel. If you encounter a bug with Business SDK (Python), please report the issue at our developer bug reporting channel.