How to publish on instagram using graph API?

Summary

I have been trying to publish reels on Instagram using the Instagram API. However, none of my attempts have worked so far.

My setup

  • I’m using an un-audited app on developers.facebook.com
  • I want to publish on an instagram page I own (business account)
  • This page was added to the app as an instagram tester

Documentation used

I have been following this page of the documentation on developers.facebook.com

My process

Step 1: OAuth

This part I did directly from the developer dashboard. The token I got has the following permissions:

  • business_basic
  • business_manage_messages
  • business_content_publish
  • business_manage_comments

Step 2: Create media container

For this part I’m doing just like the documentation says.

def create_instagram_media_container(ig_id: str, video_url: str, access_token: str):
    url = f"https://graph.instagram.com/v20.0/{ig_id}/media"
    headers = {
        "Content-Type": "application/json",
    }
    data = {
        "media_type": "REELS",
        "video_url": video_url
    }
    response = requests.post(url, headers=headers, json=data)

    if response.status_code == 200:
        return response.json()
    else:
        response.raise_for_status()

I am able to get a container ID with this step.

Note: After reading materials online, I have tried a few variations, including adding "Authorization": f"OAuth {access_token}" to the header and "upload_type": "resumable" to the data, but this didn’t fixed it.

Step 3: Publish container

Once again, I am following the documentation.

def upload_instagram_video(ig_id: str, ig_container_id: str, access_token: str):
    url = f"https://graph.instagram.com/v20.0/{ig_id}/media_publish"
    headers = {
        "Content-Type": "application/json"
    }
    data = {
        "creation_id": ig_container_id,
    }
    response = requests.post(url, headers=headers, json=data)

    if response.status_code == 200:
        return response.json()
    else:
        response.raise_for_status()

At this stage however, I get an error.

At first I had the following description:

b'{"error":{"message":"Unsupported post request. Object with ID '[...]' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AKe1_Gl1c5kNSTrKHPYuyHG"}}'

But now I just get a 400 error stating “Sorry, this content isn’t available right now”.

Note: After reading materials online, I have also tried adding "Authorization": f"OAuth {access_token}" to the header here, but this didn’t fixed it.

My thoughts

I have a few ideas as to where the confusion could be comming from, but I didn’t really manage to make anything out of them.

  • Endpoints: I am querying the graph.instagram.com endpoint, but there is also a graph.facebook.com. This seemed a bit more complete, as the documentation mentions extra fields like caption, but I didn’t manage to make it work either. I think I should still go with the Instagram one as the documentation states that “Unlike the Instagram API with Facebook Login, this API doesn’t require a Facebook Page linked to the Instagram professional account.” which seems simpler.
  • Token: Reading online, I could see some mentions of a difference between a page token and a user token. I didn’t really understand the distinction. I generated my token directly from the “Instagram” tab of the developer website, and there is no such distinction there.

After trying for several days in a row, I am now completely lost. Your help would be greatly appreciated. Thank you!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật