Twurl Status 400 Bad Request to FINALIZE

video

#1

Hi,

When trying to upload a video .mp4 return “status: 400 Bad Request\r\n” with FINALIZE comand

logs:

twurl -H upload.twitter.com “/1.1/media/upload.json” -d “command=INIT&media_type=video/mp4&total_bytes=468833” -t

command=INIT&media_type=video%2Fmp4&total_bytes=468833"
-> “HTTP/1.1 202 Accepted\r\n”
-> “cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=
0\r\n”
-> “connection: close\r\n”
-> “content-disposition: attachment; filename=json.json\r\n”
-> “content-encoding: gzip\r\n”
-> “content-length: 99\r\n”
-> “content-type: application/json;charset=utf-8\r\n”
-> “date: Thu, 22 Dec 2016 15:29:51 GMT\r\n”
-> “expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n”
-> “last-modified: Thu, 22 Dec 2016 15:29:51 GMT\r\n”
-> “pragma: no-cache\r\n”
-> “server: tsa_b\r\n”
-> “set-cookie: lang=es; Path=/\r\n”
-> “set-cookie: guest_id=v1%3A148242059126461676; Domain=.twitter.com; Path=/; E
xpires=Sat, 22-Dec-2018 15:29:51 UTC\r\n”
-> “status: 202 Accepted\r\n”
-> “strict-transport-security: max-age=631138519\r\n”
-> “vary: Origin\r\n”
-> “x-access-level: read-write\r\n”
-> “x-connection-hash: 04de322cd0213edb0efda76eac878e3d\r\n”
-> “x-frame-options: SAMEORIGIN\r\n”
-> “x-mediaid: 811956926296784896\r\n”
-> “x-rate-limit-limit: 200\r\n”
-> “x-rate-limit-remaining: 198\r\n”
-> “x-rate-limit-reset: 1482423259\r\n”
-> “x-response-time: 78\r\n”
-> “x-transaction: 00c1be2000b689d9\r\n”
-> “x-tsa-request-body-time: 2\r\n”
-> “x-twitter-response-tags: BouncerCompliant\r\n”
-> “x-xss-protection: 1; mode=block\r\n”
-> "\r\n"
reading 99 bytes…
-> “”
-> “\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x00\xAAV\xCAMM\xC9L\x8C\xCFLQ\xB2\xB204\x
B445\xB3423\xB243\xB70\xB1\xB04\xD3\x81\xCB\xC6\x17\x97\x14e\xE6\xA5+Y)a\xAAR\xD
2QJ\xAD(\xC8,J-\x8EOL+I-\x8A/NM.\x06\x1AgfliY\v\x00\x00\x00\xFF\xFF\x03\x00\xE8
xEA\x8Aha\x00\x00\x00”
{“media_id”:811956926296784896,“media_id_string”:“811956926296784896”,“expires_a
fter_secs”:86399}read 99 bytes
Conn close

twurl -H upload.twitter.com “/1.1/media/upload.json” -d “command=APPEND&media_id=811956926296784896&segment_index=0” --file 00598021AB444046BA426654D1F75117.mp4 --file-field media -t

-> “HTTP/1.1 204 No Content\r\n”
-> “cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=
0\r\n”
-> “connection: close\r\n”
-> “content-length: 0\r\n”
-> "content-security-policy: default-src 'self; connect-src 'self; font-src 's

6ZTJNRSWE2LSMQ%3D%3D%3D%3D%3D%3D&ro=false;\r\n"
-> “content-type: text/html;charset=utf-8\r\n”
-> “date: Thu, 22 Dec 2016 15:33:14 GMT\r\n”
-> “expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n”
-> “last-modified: Thu, 22 Dec 2016 15:33:14 GMT\r\n”
-> “pragma: no-cache\r\n”
-> “server: tsa_b\r\n”
-> “set-cookie: lang=es; Path=/\r\n”
-> “set-cookie: guest_id=v1%3A148242079404125675; Domain=.twitter.com; Path=/; E
xpires=Sat, 22-Dec-2018 15:33:14 UTC\r\n”
-> “status: 204 No Content\r\n”
-> “strict-transport-security: max-age=631138519\r\n”
-> “vary: Origin\r\n”
-> “x-access-level: read-write\r\n”
-> “x-connection-hash: 22dce02df3088296eec97b3d5eaeb404\r\n”
-> “x-frame-options: SAMEORIGIN\r\n”
-> “x-mediaid: 811956926296784896\r\n”
-> “x-rate-limit-limit: 20000\r\n”
-> “x-rate-limit-remaining: 19998\r\n”
-> “x-rate-limit-reset: 1482423367\r\n”
-> “x-response-time: 106\r\n”
-> “x-segmentcount: 0\r\n”
-> “x-totalbytes: 0\r\n”
-> “x-transaction: 0067940800338e1e\r\n”
-> “x-tsa-request-body-time: 13\r\n”
-> “x-twitter-response-tags: BouncerCompliant\r\n”
-> “x-xss-protection: 1; mode=block\r\n”
-> "\r\n"
Conn close

twurl -H upload.twitter.com “/1.1/media/upload.json” -d “command=FINALIZE&media_id=811956926296784896” -t

command=FINALIZE&media_id=811956926296784896"
-> “HTTP/1.1 400 Bad Request\r\n”
-> “cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=
0\r\n”
-> “connection: close\r\n”
-> “content-disposition: attachment; filename=json.json\r\n”
-> “content-encoding: gzip\r\n”
-> “content-length: 117\r\n”
-> “content-type: application/json;charset=utf-8\r\n”
-> “date: Thu, 22 Dec 2016 15:42:48 GMT\r\n”
-> “expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n”
-> “last-modified: Thu, 22 Dec 2016 15:42:48 GMT\r\n”
-> “pragma: no-cache\r\n”
-> “server: tsa_b\r\n”
-> “set-cookie: lang=es; Path=/\r\n”
-> “set-cookie: guest_id=v1%3A148242136854574698; Domain=.twitter.com; Path=/; E
xpires=Sat, 22-Dec-2018 15:42:48 UTC\r\n”
-> “status: 400 Bad Request\r\n”
-> “strict-transport-security: max-age=631138519\r\n”
-> “vary: Origin\r\n”
-> “x-access-level: read-write\r\n”
-> “x-connection-hash: 45a75096a96554134ab3dd6db70c2f02\r\n”
-> “x-frame-options: SAMEORIGIN\r\n”
-> “x-rate-limit-limit: 615\r\n”
-> “x-rate-limit-remaining: 613\r\n”
-> “x-rate-limit-reset: 1482423446\r\n”
-> “x-response-time: 216\r\n”
-> “x-transaction: 00c6b48a00ab9ced\r\n”
-> “x-tsa-request-body-time: 1\r\n”
-> “x-twitter-response-tags: BouncerCompliant\r\n”
-> “x-xss-protection: 1; mode=block\r\n”
-> “\r\n"
reading 117 bytes…
-> “”
-> “\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x00\f\xCA1\x0E\xC3 \f\x05\xD0\xABX\x9E+P
xD6^\xA3+\v\x92\x7F”*\x82\x891\x19\x12\xF5\xEE\xCD\xF6\x86w\xB3\xE1\x98\x18\xCE
oNq\tK\x8A;\xA4\xE4\x14g\xAF\x9A%|\x876~1\xCC\xD4\x9E\xF3\xC1\xB6\xA3\xF9 Qj\xEA
\x94Ehvr\xA5nz\x16\x81<\xF6\i-\x154\xCA\x85\xC0\xBF?\x00\x00\x00\xFF\xFF\x03\x0
0\xFB\xA0\xD5\ve\x00\x00\x00”
{“request”:"/1.1/media/upload.json",“error”:“Segments do not add up to provid
ed total file size.”}read 117 bytes
Conn close

This is the results of media inspector tool

General Information

Format (Long) QuickTime / MOV
Format (Short) mov,mp4,m4a,3gp,3g2,mj2
Number of Streams 2
Duration 11.058000
Size (Bytes) 468833
Bit Rate 339181
Streams

Stream (video)
Codec (Long) H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
Codec (Short) h264
Dimensions 456x394
Bit Rate 208083
Duration 11.000000
Avg Frame Rate 15/1
Stream (audio)
Codec (Long) AAC (Advanced Audio Coding)
Codec (Short) aac
Bit Rate 128023
Duration 11.057052
Sample Rate 44100

I need Help for this issue…

Thanks


#2

Are you able to share a link to the original file?

Are you able to upload the file using the large file upload sample?

Thank you and apologies for the delayed attention.


#3

Hi @andypiper ,

I could upload file using https://github.com/twitterdev/large-video-upload-python

C:\large-video-upload-python-master>python async-upload.py
INIT
Media ID: 818819733663449089
APPEND
468833 of 468833 bytes uploaded
Upload chunks complete.
FINALIZE
{‘media_id’: 818819733663449089, ‘media_id_string’: ‘818819733663449089’, ‘size’
: 468833, ‘expires_after_secs’: 86400, ‘processing_info’: {‘state’: ‘pending’, ‘
check_after_secs’: 5}}
Media processing status is pending
Checking after 5 seconds
STATUS
Media processing status is succeeded

But what can be the problem with my procedure…?

Thanks for your support.


#4

Given the error you were seeing (about chunks not adding up) it may be related to the way you are doing the chunking. It looks like you’re using a single chunk. Is the Python code doing the same thing as your twurl method precisely?


#5

Yes @andypiper , with Twurl we use the same method, only that we upload the file in a single chunk since it weighs less than 5 Mb. You think I should upload the file in several chunk despite its weight?


#6

Hi @andypiper,

I have another question, with the script you sent me can I upload only files that are on my PC?, or can I upload files that are in a remote location by providing a link?


#7

That particular script is a sample intended just to show how to use the media upload endpoints. It requires that you have the file to upload on the local filesystem.


#8

ok @andypiper, with Twurl we use the same method, only that we upload the file in a single chunk since it weighs less than 5 Mb. You think I should upload the file in several chunk despite its weight?