Search code examples
javascriptnode.jsfacebookfacebook-marketing-api

Facebook marketing API : Param must be a valid Instagram account id


I'm using again the Facebook Marketing API. I successfully managed to create Facebook ads with my Node.js app, now I want to create ad for Instagram.

To create an AdCreative, my call is as follows:

 fb.api('/act_' + rows[0].ad_act + '/adcreatives', 'post', {
   "name": "Test Instagram",
   "object_story_spec": {
     "page_id": "XXXXX",
     "instagram_actor_id": "YYYYY",
     "link_data": {
       "call_to_action": {
         "type": "LEARN_MORE",
         "value": {
           "link": "http://example.com"
         }
       },
       "image_hash": imgHash,
       "link": "http://url.com",
       "message": "Message test",
       "caption": "caption text",
     },
   }
 });

But the API always return the same message:

{ message: '(#100) Param  must be a valid Instagram account id',
  type: 'OAuthException',
  code: 100,
  fbtrace_id: 'Dr1XrUANRGr' }

rows[0].ad_act is the right account ID.

XXXX is a valid page id for that ad account.

YYYY is a valid instagram ID that is set as the instagram ads account for the page (setting into FB).

I tried different Instagram accounts as well as pages.


Solution

  • This is the answer :

    had to get the instagram_actor_id which is NOT the instagram_account_id.

    Graph API : /someFbPageID/instagram_accounts will return instagram account as a graphEdge then get the id of that object, its the instagram_actor_id