Video upload failing with error 325 (media id not found) after successful upload + status

video

#1

Hi,

I’m having trouble uploading certain videos. Most videos will upload perfectly, but I have 2 which fail systematically with this error when I try to reference them in a tweet:

"errors": [{
	"code": 325,
	"message": "A media id was not found."
}]

The videos are in the correct format for Twitter.

Here’s the upload sequence (captured using Charles Web Debugging Proxy)

  1. I send the INIT:

    total_bytes 90413
    command INIT
    media_category amplify_video
    media_type video/mp4

  2. I get the response

    {
    “media_id”: 725304998159114242,
    “media_id_string”: “725304998159114242”,
    “expires_after_secs”: 15552000
    }

  3. I upload the chunk:

    segment_index 0
    command APPEND
    media_id 725304998159114242
    media video.mp4

  4. I get a successful response:

HTTP/1.1 204 No Content

  1. I finalise:

    command FINALIZE
    media_id 725304998159114242

  2. I’m told to wail:

    {
    “media_id”: 725304998159114242,
    “media_id_string”: “725304998159114242”,
    “size”: 90413,
    “expires_after_secs”: 15552000,
    “processing_info”: {
    “state”: “pending”,
    “check_after_secs”: 5
    }
    }

  3. 5 secs later I check the status:

    command STATUS
    media_id 725304998159114242

  4. Processing succeeds:

    {
    “media_id”: 725304998159114242,
    “media_id_string”: “725304998159114242”,
    “size”: 90413,
    “processing_info”: {
    “state”: “succeeded”,
    “progress_percent”: 100
    }
    }

  5. I try to Tweet:

    status My Text
    media_ids 725304998159114242

  6. I get this error:

    “errors”: [{
    “code”: 325,
    “message”: “A media id was not found.”
    }]

What could cause this error?


#2

I have the same issue here: Uploading video chunked error on FINALIZE command

Maybe its good to combine these 2?

@tushargj @andypiper


#3

If is a video you should use video_id instead of media_ids


#4

Getting the same error when trying to create video object

twurl -X POST -H ads-api.twitter.com “/0/accounts/18ce547288m/videos?account_id=18ce547288m&video_media_id=745183785377923072”
{“errors”:[{“code”:“NOT_FOUND”,“message”:“Media not found”}],“request”:{“params”:{“video_media_id”:745183785377923072,“account_id”:“18ce547288m”}}}Abhisheks-MacBook-Pro-3:Downloads abhishekanand$

The Chunked Video upload processes successfully (INIT, APPEND, FINALIZE and STATUS), can someone point in the right direction, could there be a problem with the chunked upload? (the step before this one)

@hector_borras @JBabichJapan


#5

Hi @abhishek_pyro,

I need your upload request (simplified without the DATA parameter) to get more info about the error.

Thanks


#6

Hey @hector_borras

here you go

INIT

HttpRequest{requestMethod=POST, url=‘https://upload.twitter.com/1.1/media/upload.json’, postParams=[PostParameter{name=‘command’, value=‘INIT’, file=null, fileBody=null}, PostParameter{name=‘media_type’, value=‘video/mp4’, file=null, fileBody=null}, PostParameter{name=‘media_category’, value=‘amplify_video’, file=null, fileBody=null}, PostParameter{name=‘additional_owners’, value=‘23996599’, file=null, fileBody=null}, PostParameter{name=‘total_bytes’, value=‘752331’, file=null, fileBody=null}], authentication=OAuthAuthorization{consumerKey=‘TP7ebHOCMLv9Xd9nkT20Q’, consumerSecret=’******************************************’, oauthToken=AccessToken{screenName=‘null’, userId=3187600722}}, requestHeaders={X-Twitter-Client-URL=https://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT.xml, X-Twitter-Client=Twitter4J, Accept-Encoding=gzip, User-Agent=twitter4j https://twitter4j.org/ /3.0.4-SNAPSHOT, X-Twitter-Client-Version=3.0.4-SNAPSHOT}, requestBody=null}

{“media_id”:745506737361289216,“media_id_string”:“745506737361289216”,“expires_after_secs”:15551999}

APPEND

HttpRequest{requestMethod=POST, url=‘https://upload.twitter.com/1.1/media/upload.json’, postParams=[PostParameter{name=‘command’, value=‘APPEND’, file=null, fileBody=null}, PostParameter{name=‘media_id’, value=‘745506737361289216’, file=null, fileBody=null}, PostParameter{name=‘media’, value=‘null’, file=file, fileBody=java.io.ByteArrayInputStream@4e3f1d55}, PostParameter{name=‘segment_index’, value=‘0’, file=null, fileBody=null}], authentication=OAuthAuthorization{consumerKey=‘TP7ebHOCMLv9Xd9nkT20Q’, consumerSecret=’******************************************’, oauthToken=AccessToken{screenName=‘null’, userId=3187600722}}, requestHeaders={X-Twitter-Client-URL=https://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT.xml, X-Twitter-Client=Twitter4J, Content-Length=752331, Accept-Encoding=gzip, User-Agent=twitter4j https://twitter4j.org/ /3.0.4-SNAPSHOT, X-Twitter-Client-Version=3.0.4-SNAPSHOT}, requestBody=null}

Response Status204

FINALIZE

HttpRequest{requestMethod=POST, url=‘https://upload.twitter.com/1.1//media/upload.json’, postParams=[PostParameter{name=‘command’, value=‘FINALIZE’, file=null, fileBody=null}, PostParameter{name=‘media_id’, value=‘745506737361289216’, file=null, fileBody=null}], authentication=OAuthAuthorization{consumerKey=‘TP7ebHOCMLv9Xd9nkT20Q’, consumerSecret=’******************************************’, oauthToken=AccessToken{screenName=‘null’, userId=3187600722}}, requestHeaders={X-Twitter-Client-URL=https://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT.xml, X-Twitter-Client=Twitter4J, Accept-Encoding=gzip, User-Agent=twitter4j https://twitter4j.org/ /3.0.4-SNAPSHOT, X-Twitter-Client-Version=3.0.4-SNAPSHOT}, requestBody=null}

{“media_id”:745506737361289216,“media_id_string”:“745506737361289216”,“size”:752331,“expires_after_secs”:15552000,“processing_info”:{“state”:“pending”,“check_after_secs”:5}}

STATUS

HttpRequest{requestMethod=GET, url=‘https://upload.twitter.com/1.1/media/upload.json?command=STATUS&media_id=745506737361289216’, postParams=[], authentication=OAuthAuthorization{consumerKey=‘TP7ebHOCMLv9Xd9nkT20Q’, consumerSecret=’******************************************’, oauthToken=AccessToken{screenName=‘null’, userId=3187600722}}, requestHeaders={X-Twitter-Client-URL=https://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT.xml, X-Twitter-Client=Twitter4J, Accept-Encoding=gzip, User-Agent=twitter4j https://twitter4j.org/ /3.0.4-SNAPSHOT, X-Twitter-Client-Version=3.0.4-SNAPSHOT}, requestBody=null}

{“media_id”:745506737361289216,“media_id_string”:“745506737361289216”,“size”:752331,“expires_after_secs”:15551968,“processing_info”:{“state”:“succeeded”,“progress_percent”:100}}

POST VIDEOS

HttpRequest{requestMethod=POST, url=‘https://ads-api.twitter.com/0/accounts/18ce547288m/videos’, postParams=[PostParameter{name=‘video_media_id’, value=‘745506737361289216’, file=null, fileBody=null}], authentication=OAuthAuthorization{consumerKey=‘TP7ebHOCMLv9Xd9nkT20Q’, consumerSecret=’******************************************’, oauthToken=AccessToken{screenName=‘null’, userId=3187600722}}, requestHeaders={X-Twitter-Client-URL=https://twitter4j.org/en/twitter4j-3.0.4-SNAPSHOT.xml, X-Twitter-Client=Twitter4J, Accept-Encoding=gzip, User-Agent=twitter4j https://twitter4j.org/ /3.0.4-SNAPSHOT, X-Twitter-Client-Version=3.0.4-SNAPSHOT}, requestBody=null}

{“errors”:[{“code”:“INVALID_MEDIA_ID”,“message”:“Media referenced by media_id id was not found.”}],“request”:{“params”:{}}}

Video details

Using the HttpClient (older version) of Twitter4j, its just that the response to individual chunk APPENDS is 204 with no content so not able to figure out whats wrong here.

Thanks


#7

Hi @abhishek_pyro,

Next time, please, put your content without any related library, like :

url: https://…

params:

{ "param1":"value1" }

This will be easier to understand.

Anyway, I’ve analyzed your params all looks correct. I have 2 possible ideas of what’s wrong:

1 - Authorization process (I mean, to other users and the user has the oauthtokens) is incorrect. Are you uploading the video with an Ads Account and after, trying to post it to another account?
2 - Are you iterating over APPEND to make all the calls that are neeed?

I know the process is OK because Yesterday I’ve uploaded (and posted) a video without any problem

Regards


#8

Hey @hector_borras

Sorry for about the verbose response, Yes it seems the Authorization is the problem here, The Media calls are going to the Ad Account instead of the User account, I was under the impression an Ad Account is higher up on the tree than a User account, so uploading media there would implicitly associate itself with its user accounts. My Bad.

Thanks for the help here, really appreciate it.