0

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)
andkjaer
  • 3,995
  • 10
  • 36
  • 45
  • As per the documentation: https://developers.facebook.com/docs/marketing-api/reference/ad-creative#branded-content-posts I guess you are passing incorrect params here. – Chetan Tete Apr 06 '22 at 17:54

1 Answers1

0

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);

zhao
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 16 '22 at 14:44