@ulsoz you’re close but there are a few issues with the request.
- The
ta_partner bucket requires that you set an X-TON-Expires header. You can read more about about that here.
From our TON API documentation:
Buckets
For Tailored Audiences, please use the bucket name ta_partner.
Note that the ta_partner bucket also requires the X-TON-Expires header to be set with an expiration date up to 7 days from the current date (see the ton-upload example script for more detail). For all other TON API buckets, this header is optional however it’s safe and a good practice to pass this header all the time and buckets that do not require it will simply ignore it.
- A
Content-Type of application/x-www-form-urlencoded is never permitted in the TON API.
You’re setting the Content-Type correctly, but it looks like you’re using an older version of twurl where it was errantly forcing Content-Type to application/x-www-form-urlencoded on all requests. Ensure you’re running twurl v0.9.3 or higher so that you don’t run into this issue.
gem uninstall --force twurl && gem install twurl -v 0.9.3
Once you have those issues corrected, you should be able to do the following:
twurl -t -H ton.twitter.com /1.1/ton/bucket/ta_partner -X POST -A "Content-Type: text/plain" -A "X-TON-Expires: Sat, 05 Sep 2015 23:01:50 GMT" -A "Content-Length: 12" --data "aaa@test.com"
opening connection to ton.twitter.com:443...
opened
starting SSL for ton.twitter.com:443...
SSL established
<- "POST /1.1/ton/bucket/ta_partner HTTP/1.1\r\nContent-Type: text/plain\r\nX-Ton-Expires: Sat, 05 Sep 2015 23:01:50 GMT\r\nContent-Length: 12\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: OAuth gem v0.4.7\r\nAuthorization: OAuth oauth_body_hash=\"ZmqMusMfLNliIT45yUqjwqfwUQ0%3D\", oauth_consumer_key=\"OIDntXZULiYrCzSBq23BQ\", oauth_nonce=\"NdZHTLBog4yXkJ7NUDOMHvzSvXEsRCTgKOiPaNyxeIA\", oauth_signature=\"xNPQBV6Pv8JvoK8Wyj%2BnNfvdGLQ%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1440631051\", oauth_token=\"15678855-Q9DtXWXni83LwkqPcUl3dBkhtr9VgHu02nLKueKMI\", oauth_version=\"1.0\"\r\nConnection: close\r\nHost: ton.twitter.com\r\n\r\n"
<- "aaa@test.com"
-> "HTTP/1.1 201 Created\r\n"
-> "connection: close\r\n"
-> "content-length: 0\r\n"
-> "content-type: text/plain\r\n"
-> "date: Wed, 26 Aug 2015 23:17:31 GMT\r\n"
-> "location: /1.1/ton/data/ta_partner/15678855/qpO2_-TSjGA8rXA.txt\r\n"
-> "server: tsa_a\r\n"
-> "set-cookie: guest_id=v1%3A144063105152928411; Domain=.twitter.com; Path=/; Expires=Fri, 25-Aug-2017 23:17:31 UTC\r\n"
-> "strict-transport-security: max-age=631138519\r\n"
-> "x-connection-hash: 68aef5ab65b6e2d72d3f9d020322c43e\r\n"
-> "x-rate-limit-limit: 90000\r\n"
-> "x-rate-limit-remaining: 89999\r\n"
-> "x-rate-limit-reset: 1440631951\r\n"
-> "x-response-time: 13\r\n"
-> "x-tsa-request-body-time: 47\r\n"
-> "\r\n"
reading 0 bytes...
-> ""
read 0 bytes
Conn close