You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Instagram Graph API轮播帖上传报错:附件数量不符(错误码100)

解决Instagram Graph API轮播帖创建的附件数量错误问题

问题核心原因

你遇到的错误本质是**children参数传递格式不符合API要求**。Instagram Graph API要求轮播的子媒体ID必须是逗号分隔的字符串,而非直接传入列表。当你通过requests.post的data参数传递列表时,会被自动编码为多个重复的children键值对,导致API无法识别为有效的轮播附件集合。

同时也需要提前确认:

  • 传入的两个子媒体ID是否是通过第一步上传接口成功创建的(即调用/media上传单媒体后返回的有效ID,且响应中status字段为FINISHED)
  • 使用的API版本(v15.0)本身支持轮播帖创建(v10.0+均支持,此点无问题)

修复后的代码

修改carouselcontainer函数中payload的children字段,将列表转为逗号分隔的字符串即可:

import requests
import json

def carouselcontainer(item_ids,caption):
    # 创建轮播容器
    post_url = 'https://graph.facebook.com/v15.0/{}/media'.format(account_id)
    payload = {
        'caption' : caption,
        'media_type' : 'CAROUSEL',
        # 将列表转为逗号分隔的字符串格式
        'children': ','.join(item_ids),
        'access_token' : access_token
    }
    r = requests.post(post_url, data=payload)
    print(r.text)
    result = json.loads(r.text)
    if 'id' in result:
         return result['id']

print(carouselcontainer(['17983349911631232', '179288683854321234'],'test caption'))

额外验证步骤

  1. 单独调用子媒体上传接口,确认每个子ID对应的响应中status字段为FINISHED,只有状态完成的媒体才能被加入轮播
  2. 检查account_id是否为有效的Instagram业务账户ID(非个人账号ID)
  3. 确认access_token已获取instagram_basic、pages_show_list、pages_manage_posts、instagram_content_publish这些必要权限

内容的提问来源于stack exchange,提问作者Tarun

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 23:41:10