Facebook Marketing API create Ad Creatives Error

163 views Asked by At

I'm having issues creating Ad Creatives using:

gem 'facebookbusiness'
Facebook API version 13.0

I have successfully managed to upload Ad Images and to get the image URL and image hash in return.

The error happens when trying to create the Ad Creatives

creative = @ad_account.adcreatives.create({
  title: 'My Page Like Ad',
  body: 'Like My Page',
  object_url: 'www.facebook.com',
  link_url: 'www.facebook.com',
  image_url: image[0]['url'],
  image_hash: image[0]['hash'],
})

I get this error:

FacebookAds::ClientError in Admins::AdsController
Invalid parameter: Missing Image (fbtrace_id: Ao0FDSCOwt9ss_5W6CmNyhx)
1

There are 1 answers

1
zhao On

you should special in field object_story_spec,not in image_hash

final AdCreativeObjectStorySpec objectStorySpec = new AdCreativeObjectStorySpec()
    .setFieldVideoData(new AdCreativeVideoData()
                        .setFieldVideoId(video.getFieldId())
                        .setFieldImageHash(image.getFieldHash())
                        .setFieldCallToAction(callToAction))
                        .setFieldPageId(String.valueOf(page.getId()));
account.createAdCreative()
                .setObjectStorySpec(objectStorySpec);