A
A
Adam2021-09-23 16:40:49
Python
Adam, 2021-09-23 16:40:49

Facebook API Marketing how to solve creative problem?

I'm making a request to the Facebook Marketing API to generate an ad creative, the code looks like this:

def CreateDoLink(self, ad_acc_id, name, link, message, page_id, typeBtn):
        st = "https://graph.facebook.com/v11.0/act_" + ad_acc_id + "/adcreatives"

        post = {"name": name,
                #"ad_format": "COLLECTION",
                "object_story_spec": {
                    "link_data": {
                        "call_to_action": {"type":typeBtn,"value":{"link":link}},
                        "link": link,
                        "message": message
                    },
                    "description": "this is description",
                    "page_id":page_id
                },
                "access_token": self.access_token
                }
        req = requests.post(st, data=post)
        return req.text

When I run the code, I get this error:

{"error":{"message":"Invalid parameter","type":"OAuthException","code":100,"error_subcode":1815166,"is_transient":false,"error_user_title":"Invalid creative's object story spec","error_user_msg":"<b>Invalid creative's object story spec, please check the format of your object story spec.</b>"

How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question