subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.32k stars 683 forks source link

[BUG] Clip Upload Error: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/media/configure_to_clips/?video=1 #813

Open jimmyxp01 opened 2 years ago

jimmyxp01 commented 2 years ago

I'm using Ubuntu,

from instagrapi import Client
from instagrapi.types import StoryMention, StoryMedia, StoryLink, StoryHashtag
cl = Client()
cl.load_settings('/dump.json')
cl.login('ID', 'Pass') #2 step verification activate 

media = cl.clip_upload(

        r"time.mp4",
        "time\n",

        extra_data={
            "custom_accessibility_caption": "time",
            "share_to_facebook": 1,
        }
    )

Error:

Traceback (most recent call last):
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 298, in _send_private_request
    response.raise_for_status()
  File "/home/june/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/media/configure_to_clips/?video=1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 434, in private_request
    self._send_private_request(endpoint, **kwargs)
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 330, in _send_private_request
    raise ChallengeRequired(**last_json)
instagrapi.exceptions.ChallengeRequired: challenge_required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 298, in _send_private_request
    response.raise_for_status()
  File "/home/june/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/media/configure_to_clips/?video=1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/june/Desktop/News/assets/test.py", line 8, in <module>
    media = cl.clip_upload(
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/clip.py", line 191, in clip_upload
    raise e
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/clip.py", line 171, in clip_upload
    configured = self.clip_configure(
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/clip.py", line 267, in clip_configure
    return self.private_request(
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 451, in private_request
    return self._send_private_request(endpoint, **kwargs)
  File "/home/june/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 330, in _send_private_request
    raise ChallengeRequired(**last_json)
instagrapi.exceptions.ChallengeRequired: challenge_required

Note: This file working 2 days ago but now it's not working

vapefy commented 2 years ago

instagrapi.exceptions.ChallengeRequired: challenge_required appears when a user is trying to access their Instagram account via the web rather than the app, or when you are trying to login to your account from a new unrecognised device. log in to the account via app and accept the challenge or check your mails.

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/media/configure_to_clips/?video=1 is only the exception which results from not being able to do actions.

brunocardone commented 2 years ago

I'm with the same issue here. I'm accepting the challenge with the app but still having these error requests.exceptions.HTTPError: 400 Client Error: Bad Request for url:

brunocardone commented 2 years ago

I found something that works for me: Add this before your login:

def challenge_code_handler(username, choice):
    if choice == ChallengeChoice.SMS:
        return get_code_from_sms(username)
    elif choice == ChallengeChoice.EMAIL:
        return get_code_from_email(username)
    return False

cl = Client()
cl.challenge_code_handler = challenge_code_handler

Then, click on cl.login and search for Xiaomi. Then, change parameters android_release, manufacturer, and model to your mobile's settings (for example my phone's android release is 12.0.0, the manufacturer is Samsung and the model is SM-G780G). I hope it works for you too.