Media Post Failing


#1

Hello,

We are having a strange issue where a post will fail when regularly processed. However, if we step through the code slowly to try and diagnose the issue we notice that it will resolve completely so it seems like it may have to do with the speed at which calls are being made to the API.

We are uploading a video which is a multi-step process:

Initial API call to start video upload:

https://upload.twitter.com/1.1/media/upload.json
parameters:
additional_owners: 368230671
media_category: "tweet_video"
command: "INIT"
media_type: "video/mp4"
total_bytes:{video size in bytes}

API call to upload video data to:

https://upload.twitter.com/1.1/media/upload.json
parameters:
command: "APPEND"
media_id:{id returned from initial api call}
segment_index: {section of video being uploaded}

API call to finish upload:

https://upload.twitter.com/1.1/media/upload.json
parameters:
command: "FINALIZE"
media_id: {id returned from initial api call}

API call to check processing status until complete:

https://upload.twitter.com/1.1/media/upload.json
parameters:
command: "STATUS"
media_id: {id returned from initial api call}

API call to post:
https://api.twitter.com/1.1/statuses/update.json
parameters:
status: "Match night is approaching and it’s your time to be the hero - stock up on your cold ones and be part of the action. #ShareTheDrama"
media_ids: {id from video upload}

I have uploaded the video being used to dropbox so you can use it to test: https://www.dropbox.com/s/daqh0zyp305gcox/202384.mp4?dl=0


#2

I just successfully uploaded and posted this using the large video upload sample code and it seems to work OK. What exactly is failing?


#3

Hi Andy,

The video upload process usually goes through fine, it is when trying to publish the post with the video attached that ends up failing. If you do not try to post the video the previous API calls all work properly. A regular Twitter post without the video attachment also posts fine.


#4

We are still encountering this issue. Do you have any insights?


#5

It would be very helpful if you could provide the API calls you are making and the outcomes from the calls to the Twitter API endpoints. Thank you.


#6

Hi @andypiper

It seems to be failing on this call:
api call to post:
https://api.twitter.com/1.1/statuses/update.json
parameters:
status:

{message}
media_ids:

{id from video upload}

With a message of:
{“errors”:[

{“code”:324,“message”:“Not valid video”}
]}.

If the api call is delayed in any way, it appears to go through without error.


#7

Have you previously called the media/upload endpoint with the STATUS option to check that the media had completed encoding?


#8

Yes, we use:

api call to check processing status until complete:

https://upload.twitter.com/1.1/media/upload.json
parameters:
command: "STATUS"
media_id:

{id returned from initial api call}


#9

Are you able to provide an example media ID that you’ve attempted to upload within the past 24 hours?


#10

example media id: 971060180141133825