Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4063898
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:47:09+00:00 2026-05-20T15:47:09+00:00

The Facebook Ads API has a call for the posting of ads – and

  • 0

The Facebook Ads API has a call for the posting of ads – and it requires attaching images to the post, and setting the filename in a creative_spec and then attaching the image with that name in the multipart.

The FacebookMedia object seems right for this, but then I see in the code that only 1 media object can be attached per post. Is there a reason for this?

Here’s some (crappy, first-pass) code:

        dynamic adgroup = new ExpandoObject();
        adgroup.method = "ads.createAdGroups";
        adgroup.account_id = AdAccount.FbAdAccountId;
        adgroup.adgroup_specs = new List<dynamic>();


            dynamic adgroup_specs = new ExpandoObject();
            adgroup_specs.campaign_id = campaignid;
            adgroup_specs.name = ad.campaign_name;
            adgroup_specs.status = 1;
            adgroup_specs.bid_type = 1;
            adgroup_specs.max_bid = ad.max_bid;
            adgroup_specs.targeting = (dynamic)(new ExpandoObject());
            adgroup_specs.targeting.countries = new List<string>();
            adgroup_specs.targeting.countries.Add("US");

            adgroup_specs.creative = (dynamic)(new ExpandoObject());
            adgroup_specs.creative.title = ad.AdTitleText;
            adgroup_specs.creative.body = ad.AdCopyText;
            adgroup_specs.creative.link_url = ad.url; // TODO: ASk Bill
            adgroup_specs.creative.file_name = ad.ImageId + "_" + ad.ImageName;

            var image = dc.Images.Where(r => r.ImageId == ad.ImageId).FirstOrDefault();

            adgroup.adgroup_specs.Add(adgroup_specs);

Then I need to attach all the images, not sure how to do this. They have to be in the post with their name, so I figure I can attach them anywhere:

        var images = (from image in dc.Images
                      where image_ids.Contains(image.ImageId)
                      select image).Distinct();


        var p = adgroups as IDictionary<String, object>;

        foreach (var i in images)
        {
            FacebookMediaObject fmo = new FacebookMediaObject();
            fmo.FileName = i.ImageId + "_" + i.Name;
            fmo.SetValue(i.ImageData);
            fmo.ContentType = "image/png";
            p.Add(i.ImageId + "_" + i.Name, fmo);
        }

        dynamic dresult = FbApp.Post(adgroup);

EDIT: So this wasn’t even working with one image, I have a list of creatives and when posted without the image, it posts correct data, when posted with an image, it looks like this (look at adgroup_specs):

Host: api.facebook.com
Content-Length: 5945
Expect: 100-continue

–8cdad9aeb95b79c
Content-Disposition: form-data; name=”method”

ads.createAdGroups
–8cdad9aeb95b79c
Content-Disposition: form-data; name=”account_id”

106925396
–8cdad9aeb95b79c
Content-Disposition: form-data; name=”adgroup_specs”

System.Collections.Generic.List`1[System.Object]
–8cdad9aeb95b79c
Content-Disposition: form-data; name=”api_key”

–8cdad9aeb95b79c
Content-Disposition: form-data; name=”format”

json-strings
–8cdad9aeb95b79c
Content-Disposition: form-data; filename=”667_Screen shot 2011-02-24 at 3.46.29 PM.png”
Content-Type: image/png

It’s converting the List<> incorrectly. This works in the normal post without multipart. Is this a bug?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:47:09+00:00Added an answer on May 20, 2026 at 3:47 pm

    This looks like it is a bug. Please file it in the issue tracker on codeplex. http://facebooksdk.codeplex.com/workitem/list/basic

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Facebook has a special javascript call for setting Fanpage permissions. Unfortunately, I can't get
Is it possible to access the demographic report data in the Facebook Ads API?
[Facebook requestWithGraphPath:@1000029327084_2428832476/likes andParams:params andHttpMethod:@POST andDelegate:nil]; This is what I do for posting my like
Facebook recently added photo-tagging capabilities to its Graph API: http://developers.facebook.com/blog/post/509/ I am using FbConnect
Facebook has a new Batch request Graph API that I'm trying to consume. The
I'm trying to implement part of the facebook ads api, the auto complete function
facebook has the facebook credit and I knew that they are testing on pay
Facebook has linked accounts, where facebook logs you into facebook everytime you are logged
Facebook API: How to let the php knows whether the user is a fan
Facebook API can give the pages a user admins. Suppose that it returns me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.