I’m using the Direct Message APIs to send media and a specific mp4 is getting rejected. I have tried other files and are working fine. Here’s the exception and reason that I see,

{"HttpStatusCode":403,"Message":"{\"errors\":[{\"code\":151,\"message\":\"There was an error sending your message: Bad Media, unable to process: Some(InvalidMedia).\"}]}

I’m not able to upload the .mp4 file here in this request, but please let me know what could be causing this.

Could someone please help with this?

Are you using chunked media upload? And if so, are you waiting enough time until the STATUS request returns a success Before you include the media id in the message? https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/get-media-upload-status

Yes we use the chunked media upload and wait for few seconds before retrying. I do see that the upload was successful since I see a HTTP status code Accepted from Twitter. Here’s more info:

Media ID: 1305895441314328578
Date: 2020-09-15 15:45:12.8510561 UTC

Please let me know if you need any more info, thanks!

A successful HTTP status code is not enough, that just means the request is ok - some videos take longer to process than a few seconds after being successfully uploaded, and you can’t use them until they’re fully converted - which the STATUS request is meant to solve - so i’d keep issuing STATUS requests every few seconds until you get a response that has "processing_info":{ "state":"succeeded", "progress_percent":100, } and then you can use the media in a DM / tweet

2 Likes

I think we are checking the status code only once and not retrying. We will update the code and check again, thank you!

1 Like

Even after adding a retry this is not working :frowning: The processing_info is coming back as null.

URL: https://upload.twitter.com/1.1/media/upload.json
Method: POST

Response:
{“size”:“841773”,“processing_info”:null,“media_id”:1316881106369613824,“media_id_string”:“1316881106369613824”,“expires_after_secs”:“86400”}"}

Could you help with this please? I can share the .mp4 file if that would help

Bumping up, could someone help with this please? Really appreciate any help!

Hello, pinging again could someone help with this pls?