rawatdeepesh
rawatdeepesh

Reputation: 584

No creative spec found for given adgroup while creating Facebook ads using FB api

I have a facebook campaign, adSet and an adcreative which I have created using the Facebook API. However when I try to create an ad using these three endpoints(:I think they are called endpoints) it gives an error No creative spec found for given adgroup. Here is my code to create the ad with images,adsets and campaign earlier created:

FB.api('act_xxxxxxxx/adcreatives', 'POST', {
name: 'My Testworthy Ad Creative',
title: 'Facebook Marketing Partners',
body: 'Get exactly the things you need from your marketing.',
image_url: 'img url',
object_url: 'https://www.facebookmarketingpartners.com',
access_token:'app access token for selected permissions'

        },function(adcreativeresponse){
          console.log(adcreativeresponse.id);
          FB.api('/act_xxxxxxxx/ads','POST',  {
          creative:["{\"creative_id\" : \"adcreativeresponse.id /*or a static creative_id*/\"}"],
          name:"tryncatch",
          adset_id:"adsetId",
          status:"PAUSED",
          access_token:"app access token with the required permissions selected"},
          function(response) {
                                console.log("response for ad");
                                                 console.log(response);// 
                                                 Insert your code here
                             }
                                            );

                                        } );

As shown in the code , I create an adcreative which returns the node id of the adcreative created, which I use in the response function to create an ad with all the parameters gathered earlier, but it gives me an error as shown in the image provided after logging "response for ad". enter image description here

Is there something that I am missing here.

Upvotes: 1

Views: 2119

Answers (1)

Jun Park
Jun Park

Reputation: 548

The value for the key creative inside your param object should be:

"creative": {"creative_id":<CREATIVE_ID>} // without the array

as it states in official Facebook documentation for creating ads:

creative (AdCreative):

This field is required for create. The ID of the ad creative to be used by this ad. You can read more about creatives here. You should supply the ID within an object as follows:

{"creative_id": <CREATIVE_ID>}

Upvotes: 1

Related Questions