Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400, message: "{"request":"\/i\/media\/upload.json","error":"media parameter is missing #265

Open
bymaer opened this issue Nov 27, 2024 · 0 comments

Comments

@bymaer
Copy link

bymaer commented Nov 27, 2024

Code:

async def post_video_to_twitter(caption, video_path):

    media_id = await client.upload_media(source=video_path, wait_for_completion=True, media_type="video/mp4", media_category="tweet_video")

    tweet = await client.create_tweet(
        text=caption,
        media_ids=[media_id]
    )

Error:

in post_video_to_twitter
    media_id = await client.upload_media(source=video_path, wait_for_completion=True, media_type="video/mp4", media_category="tweet_video")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/twikit/client/client.py", line 995, in upload_media
    await append_gather
  File "/root/.venv/lib/python3.12/site-packages/twikit/client/v11.py", line 145, in upload_media_append
    return await self.upload_media(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/twikit/client/v11.py", line 112, in upload_media
    return await self.base.request(method, endpoint, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.venv/lib/python3.12/site-packages/twikit/client/client.py", line 156, in request
    raise BadRequest(message, headers=response.headers)
twikit.errors.BadRequest: status: 400, message: "{"request":"\/i\/media\/upload.json","error":"media parameter is missing."}"
INFO:httpx:HTTP Request: POST https://upload.twitter.com/i/media/upload.json?command=APPEND&media_id=1861878596425424896&segment_index=0 "HTTP/1.1 400 Bad Request"

"request":"/i/media/upload.json","error":"media parameter is missing."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant