TON api 400 bad request

ton
api

#1

Hello,

I’m trying to use the Ton API to upload a file for a tailored audience but I’m getting a 400 bad request with cUrl

This is what I get with cUrl :

POST /1.1/ton/bucket/ta_partner?resumable=true HTTP/1.1
Host: ton.twitter.com
Accept: /
Content-Length: 0
Content-Type: text/plain
X-TON-Content-Type: text/plain
X-TON-Content-Length: 5160704
Authorization: OAuth oauth_consumer_key=“xxxxxxxxxxxxxxxxx”, oauth_nonce=“1459789626”, oauth_signature_method=“HMAC-SHA1”, oauth_token=“51085369-kCLvBiCJE0wILvmHm9sajj7qSO4L5BR2KVwemuefn”, oauth_timestamp=“1459789626”, oauth_version=“1.0”, oauth_signature=“BgBQCuWURPmQUVB4hY8jRaOd9Lo%3D”

< HTTP/1.1 403 Forbidden
< content-length: 0
< date: Mon, 04 Apr 2016 17:07:07 GMT

  • Server tsa_b is not blacklisted
    < server: tsa_b
    < set-cookie: guest_id=v1%3A145978962713310055; Domain=.twitter.com; Path=/; Expires=Wed, 04-Apr-2018 17:07:07 UTC
    < strict-transport-security: max-age=631138519
    < x-connection-hash: 858d881e0a29d1d231686111493e7a90
    < x-content-type-options: nosniff
    < x-response-time: 9

and a 403 with Twurl:
twurl -t -H ton.twitter.com /1.1/ton/bucket/ta_partner -X POST -A “Content-Type: image/jpeg” -A “Content-Length: 3” --data "MY "

<- “POST /1.1/ton/bucket/ta_partner HTTP/1.1\r\nContent-Type: image/jpeg\r\nContent-Length: 3\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: /\r\nUser-Agent: OAuth gem v0.5.1\r\nAuthorization: OAuth oauth_body_hash=“lWBMvcTjEExT34UT%2B3fSp%2B%2Fok3k%3D”,
oauth_consumer_key=“xxxxxxxxxxxxxxxxxxx”, oauth_nonce=“mBUQiDxScSNDh8Kald7yrCy6zoAN9bLOEsUf23B7cQs”, oauth_signature=“8XrW6UdgQzc8nsVPwSSWJSEq8EE%3D”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1459792795”, oauth_token=“715568189212639233-a8n0EivB7J0SSdESFs3XbxsfrXV06Ue”, oauth_version=“1.0”\r\nConnection: close\r\nHost: ton.twitter.com\r\n\r\n”
<- "MY "
-> “HTTP/1.1 400 Bad Request\r\n”
-> “cache-control: no-cache\r\n”
-> “connection: close\r\n”
-> “content-length: 0\r\n”
-> “date: Mon, 04 Apr 2016 17:59:56 GMT\r\n”
-> “server: tsa_b\r\n”
-> “set-cookie: guest_id=v1%3A145979279601168163; Domain=.twitter.com; Path=/; Expires=Wed, 04-Apr-2018 17:59:56 UTC\r\n”
-> “strict-transport-security: max-age=631138519\r\n”
-> “x-connection-hash: 68b6b57f8192b565097b159247d800cd\r\n”
-> “x-content-type-options: nosniff\r\n”
-> “x-rate-limit-limit: 90000\r\n”
-> “x-rate-limit-remaining: 89999\r\n”
-> “x-rate-limit-reset: 1459793696\r\n”
-> “x-response-time: 11\r\n”
-> “x-tsa-request-body-time: 143\r\n”
-> “\r\n”

Any idea of where I’m wrong ?


#2

Hi @hidewak,

I think this is not the correct Category.

Here is the reference:

TON

I guess you should go here: https://twittercommunity.com/c/rest-api/rest-api-v1-1