Uploading video chunked error on FINALIZE command

video
media-upload
php

#1

I’m uploading a video of 10MB (MP4). All partitial uploads and INIT seems good. The finalize returns an unknown error to me.

Request status: 202

POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="609dc1a70ca334cde4aaea4a7203c519",oauth_signature="V9wSnmw08MyUlmY0IHZZB9rlvPo%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463469517",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 62

Media INFO from INIT command

Array
(
    [media_id] => 732470362185732096
    [media_id_string] => 732470362185732096
    [expires_after_secs] => 86399
)

Request status: 204

POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="609dc1a70ca334cde4aaea4a7203c519",oauth_signature="eJ8eS6aMZ8ryWcsvN%2BzpTn5QeOc%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463469517",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 5000460
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----609dc1a70ca334cde4aaea4a7203c519; boundary=----------------------------5d28ca7fc293

Request status: 204

POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="8dc15ea057450ded5a29301a4bafa109",oauth_signature="NMpWuvNplqr3LMpN9zCqzFbFrqA%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463469522",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 5000460
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----8dc15ea057450ded5a29301a4bafa109; boundary=----------------------------65463a7e48b1

Request status: 204

POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="e9fa854cedb2f6dde2165ab1c49f15b8",oauth_signature="FRRP7hd5Ny%2BxBP5KgbCCFeqBqgY%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463469524",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 1440082
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----e9fa854cedb2f6dde2165ab1c49f15b8; boundary=----------------------------a60359cfc737

Request status: 400

POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="1cf02f9bbecd4e300b8d411ebe9a2f88",oauth_signature="MG8bGilFUc3Lq%2FjgRt8Ci%2BC3oF4%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463469526",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 44
Array
(
    [request] => /1.1/media/upload.json
    [error] => InvalidContent.
)

#2

Ok, so I fixed this one. #solution is:

add: > media_category parameter with value > ‘tweet_video’.

Its not described anywhere in the documentation but hell. Kinda used to it now.


Though, when I request the status of this upload I get:

Array
(
    [media_id] => 732479606096166912
    [media_id_string] => 732479606096166912
    [size] => 11439622
    [processing_info] => Array
        (
            [state] => failed
            [progress_percent] => 100
            [error] => Array
                (
                    [code] => 0
                    [name] => InternalError
                )

        )

)

Anyone? @andypiper?


#3

Possible media_category values are currently listed in this thread while we work through some site changes. That doesn’t seem to be the underlying issue with the failed processing, though.

I’ll see if the media team can take a look at this with you.


#4

@andypiper I should add that I’m not sure if the values you’re refering to in that thread are ok, because when I tried it twitter response was that I should use “amplify_video” instead of “tweet_video”

Thanks!


#5

Hi @andypiper ,

well at least it uploads the file. I receive a media Id as you can see and i can request its status. Without the media_category it doesn’t give me a media ID. So i assume that part is correct.

I think we all can agree on the fact that the error messages from the API is far from usefull. I hope the media team can contact me and help me out with this part. Then i am close to finishing up this part of the project and i can move on to the next social platform to battle with.

Cheers!


#6

@hector_borras yes - however you are working with the Ads API where amplify_video is a different option. I’ll double-check on that, as it doesn’t make sense to have two sets of valid values.


#7

@hector_borras where did you get the ‘amplified_video’ category from? From Twitter?


#8

I’ve tried with tweet_video and Twitter api told me that I should use amplify_video and I did it and it worked!!


#9

Hahahaha yes it works! :slight_smile: #solution. Thanks @hector_borras!

It does upload my MP4:

Array
(
    [media_id] => 732540885078925312
    [media_id_string] => 732540885078925312
    [size] => 11439622
    [expires_after_secs] => 15552000
    [processing_info] => Array
        (
            [state] => pending
            [check_after_secs] => 5
        )

)

And status request shows:

Array
(
    [media_id] => 732540885078925312
    [media_id_string] => 732540885078925312
    [size] => 11439622
    [processing_info] => Array
        (
            [state] => succeeded
            [progress_percent] => 100
        )

)

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

Ok, now im getting this error when trying to tweet this video:

Request status:400
POST /1.1/statuses/update.json HTTP/1.1
Host: api.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="10d573bbe9e32872e7321dd584428e6e",oauth_signature="ykGmypzXUyIUxJ9CRPlKwGuvkKY%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463487010",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 52

Array
(
    [errors] => Array
        (
            [0] => Array
                (
                    [code] => 325
                    [message] => A media id was not found.
                )

        )

)

Looks like this: Media id not found while posting tweet with media

@andypiper or @tushargj any idea?


#11

Are you using the video_id or the media_id parameter? You should use video_id


#12

Oh! I didn’t know that! Anyway thanks @andypiper!


#13

Damn really? #omg Thanks!

@andypiper
Also, why is the documentation talking about ‘media_ids’ parameter and not mentioning ‘video_id’ parameter anywhere?


#14

hi @anypiper,

Video ID parameter is not working. As the documentation says: https://dev.twitter.com/rest/reference/post/statuses/update the parameter media_ids should be used for videos as well. Any idea?


#15

Ops, maybe this is my fault. You’re right. It parameter doesn’t exist for the rest API. I’m using the ads API, so maybe that’s the difference. Sorry for the confusion.


#16

no problem. Still trying to figure out how to post my video in a status update. It just doesn’t work if you follow the documentation.
To be absolutely sure you guys have all information:

Request status: 202
POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="d4dfaf1f67d53b7344e52e87b75dfc5f",oauth_signature="4GzIfbjFleYrJHrFNbbdrxEdnFY%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463504228",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 91

Filesize: 11439622
Media INFO from INIT command
Array
(
    [media_id] => 732615952102268929
    [media_id_string] => 732615952102268929
    [expires_after_secs] => 15552000
)
Request status: 204
POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="347b55546688fa3aed869aa89235f47d",oauth_signature="vDwF4St6BbusdCL1vV1vYQ49YV4%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463504229",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 5000460
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----347b55546688fa3aed869aa89235f47d; boundary=----------------------------b0722736c4d1

Request status: 204
POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="01ee92f01e3776303599eca156c4eb11",oauth_signature="myjgysfQZ1htIkT06lHv0%2BkurKI%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463504238",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 5000460
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----01ee92f01e3776303599eca156c4eb11; boundary=----------------------------5c97b1569216

Request status: 204
POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="843af4dd8dc5186b74ea6db2ab31c17f",oauth_signature="OKXKjhMvofd6gzpr8hp%2BWwGRuqY%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463504242",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 1440082
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----843af4dd8dc5186b74ea6db2ab31c17f; boundary=----------------------------45e48f8e093e

Request status: 200
POST /1.1/media/upload.json HTTP/1.1
Host: upload.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="30acf8d8266b67aec9f8724d0927dd51",oauth_signature="jlA1vygHV%2F9pYSvvMroIQxCMm1U%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463504245",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 44

Array
(
    [media_id] => 732615952102268929
    [media_id_string] => 732615952102268929
    [size] => 11439622
    [expires_after_secs] => 15552000
    [processing_info] => Array
        (
            [state] => pending
            [check_after_secs] => 5
        )

)
Array
(
    [media_id] => 732615952102268929
    [media_id_string] => 732615952102268929
    [size] => 11439622
    [processing_info] => Array
        (
            [state] => succeeded
            [progress_percent] => 100
        )

)
Array
(
    [oauth_consumer_key] => p3YmsQLQ8AykCjbPnXMiIHWLt
    [oauth_nonce] => 36bbf5b78aaa8e57073663a56e7d818c
    [oauth_signature_method] => HMAC-SHA1
    [oauth_timestamp] => 1463504257
    [oauth_version] => 1.0
    [oauth_token] => 23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN
    [user_secret] => dskeLd6ypccnGvHGEiRuClleJPeQRxGwGoJHqm1hZaDt6
    [status] => Tweet with video
    [media_ids] => 732615952102268929
)
Request status: 400
POST /1.1/statuses/update.json HTTP/1.1
Host: api.twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key="p3YmsQLQ8AykCjbPnXMiIHWLt",oauth_nonce="36bbf5b78aaa8e57073663a56e7d818c",oauth_signature="JTNvUNzHBK1qc4sWKeYFupSmeGs%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1463504257",oauth_token="23585732-UoAlk92K4xMVfrYFFR2ohi1rMJFtL5nAtC241vQdN",oauth_version="1.0"
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Length: 52

Array
(
    [errors] => Array
        (
            [0] => Array
                (
                    [code] => 325
                    [message] => A media id was not found.
                )

        )

)

#17

Hi @andypiper, can you please help out with this final step? Why does it not accept my media_ids?

Als @tushargj, can you please look into this? Thanks!


#18

I checked in with the team and to clarify, you should definitely not use a media_category of amplify_video unless you are on the Ads platform. Additionally, the media kind is apparently “mpeg4 (Advanced Simple Profile)” which we don’t support at the moment.

I apologise for these gaps in the documentation and I’m working with the team to clarify these things right now, but we are in the process of some other backend changes to the doc system so this may take a while to ripple through.


#19

Ok, what types of video do you support then @andypiper? My customer is waiting for this code so I hope you can answer me today.


#20

But why is this #twurl working with MP4, and normal upload doesn’t support MP4? I’m kinda lost now. Or is it the Advanced Simple Profile that is messing stuff up?