Tailored Audience TON Upload Failing with 400 Error Code

ton

#1

Since Friday I’ve been consistently getting 400 responses to my ton uploads. I am posting to https://ton.twitter.com/1.1/ton/bucket/ta_partner with csv data for Tailored Audiences. The responses come back with a 400 Error Code and no body. Before Friday, the uploads were going through fine.


Uploading hashed twitter ids to specific tailored audience
Tailored Audience TON 400 Error for Resumable Upload
#2

Could you try uploading with the ton-upload Ruby library? Does that work or are you still having issues?


#3

I also tried with the ton-upload library. I get back a response with no location. Error handling doesn’t seem to be too robust in ton-upload, so I’m not certain that this is the same 400 response.


#4

I got “400 Bad Request” again


#5

@timisbusy please share some request logs from your attempts with the ton-upload example script. You can do so by attempting a small (<8mb) upload again using the ton-upload script and pass the --trace flag as an option for verbose request logging.

Once you have that please reply back and attach your zipped log file to the post.


#6

Having the same problem at my end. Here’s the header I used to send for the post

POST https://ton.twitter.com/1.1/ton/bucket/ta_partner HTTP/1.1
Host: ton.twitter.com
User-Agent: Alche
Accept-Encoding: identity,gzip
Content-Type: text/csv
Content-Length: 6630
X-TON-Expires: Tue, 11 Aug 2015 00:20:05 GMT
Authorization: OAuth oauth_consumer_key=“oauth_consumer_key”, oauth_nonce=“oauth_nonce”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1438647605”, oauth_version=“1.0”, oauth_token=“oauth_token”, oauth_signature="oauth_signature"
Connection: Close

Tested on both twurl and ton-upload as well, got the same 400 bad request response. Here’s the trace req/log from ton_upload

Uploading email.hash.csv (0 KB) as text/comma-separated-values via TON API
opening connection to ton.twitter.com:443
opened
starting SSL for ton.twitter.com:443
SSL established
<- “POST https://ton.twitter.com/1.1/ton/bucket/ta_partner HTTP/1.1\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\nContent-Type: text/comma-separated-values\r\nContent-Length: 130\r\nX-Ton-Expires: Sun, 09 Aug 2015 00:44:39 GMT\r\nAuthorization: OAuth oauth_body_hash=“hash”, oauth_consumer_key=“oauth_consumer_key”, oauth_nonce=“mgu7M4HBTjVCDbLvur3N6jNAxgOd62LG67krUir4Q”, oauth_signature=“USdDiwo%2Fb5k7SRBxWfqR3BkFmhk%3D”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1438649079”, oauth_token=“oauth_token”, oauth_version=“1.0”\r\nConnection: close\r\nHost: ton.twitter.com\r\n\r\n”
<- “eabb220e1c2e34a53294b9868f8cff4cd21d36c1a0ec0f9bef3953a3f0ecfe5b\nf505796aac5fb17c05a95b32dbfc6cea198437714acc84b6d2caf1a22cca6e22\n”
-> “HTTP/1.1 400 Bad Request\r\n”
-> “cache-control: no-cache\r\n”
-> “connection: close\r\n”
-> “content-length: 0\r\n”
-> “date: Tue, 04 Aug 2015 00:44:39 GMT\r\n”
-> “server: tsa_a\r\n”
-> “set-cookie: guest_id=v1%3A143864907988003859; Domain=.twitter.com; Path=/; Expires=Thu, 03-Aug-2017 00:44:39 UTC\r\n”
-> “strict-transport-security: max-age=631138519\r\n”
-> “x-connection-hash: 87bbe33196dae3a5236e007446119ce9\r\n”
-> “x-rate-limit-limit: 50\r\n”
-> “x-rate-limit-remaining: 46\r\n”
-> “x-rate-limit-reset: 1438649310\r\n”
-> “x-response-time: 10\r\n”
-> “x-tsa-request-body-time: 3\r\n”
-> "\r\n"
reading 0 bytes…
-> ““
read 0 bytes
Conn close
File stored at
Downloading the file
RestClient.get “https://ton.twitter.com/1.1/ton/bucket/ta_partner/”, “Accept”=>”/; q=0.5, application/xml”, “Accept-Encoding”=>“gzip, deflate”, “Authorization”=>"Bearer "
/# => 400 BadRequest | 0 bytes
/var/lib/gems/2.1.0/gems/rest-client-1.8.0/lib/restclient/abstract_response.rb:74:in return!': 400 Bad Request (RestClient::BadRequest) from /var/lib/gems/2.1.0/gems/rest-client-1.8.0/lib/restclient/request.rb:495:inprocess_result’
from /var/lib/gems/2.1.0/gems/rest-client-1.8.0/lib/restclient/request.rb:421:in block in transmit' from /usr/lib/ruby/2.1.0/net/http.rb:853:instart’
from /var/lib/gems/2.1.0/gems/rest-client-1.8.0/lib/restclient/request.rb:413:in transmit' from /var/lib/gems/2.1.0/gems/rest-client-1.8.0/lib/restclient/request.rb:176:inexecute’
from /var/lib/gems/2.1.0/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in execute' from ./ton_upload:233:inget_from_ton’
from ./ton_upload:357:in execute' from ./ton_upload:401:inmain’
from ./ton_upload:404:in `’


#7

opening connection to ton.twitter.com:443
opened
starting SSL for ton.twitter.com:443
SSL established
<- “POST https://ton.twitter.com/1.1/ton/bucket/ta_partner HTTP/1.1\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\nContent-Type: text/comma-separated-values\r\nContent-Length: 65\r\nX-Ton-Expires: Fri, 14 Aug 2015 01:44:56 GMT\r\nAuthorization: OAuth oauth_body_hash=“2JWk84wHYwDLSJqjtdqlWaSAdoI%3D”, oauth_consumer_key=“E5uUyEGWZpqaumKotCIJTJfT4”, oauth_nonce=“nUvnlyrbQwMr0Faro9qTjv7qDym4aEvrVxfuaDy0”, oauth_signature=“wwmd3NyLhurzBhlkKd7uw0sMmD4%3D”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1438652696”, oauth_token=“501816370-NggDPSDkwJbJs6ThB4CIa2Xmu9ZWwd9ZpYCjmCZS”, oauth_version=“1.0”\r\nConnection: close\r\nHost: ton.twitter.com\r\n\r\n”
<- “dec8bdd96a4913109864aede8d2ee77c1394035d7eba28602ef48c1facb9890b\n”
-> “HTTP/1.1 400 Bad Request\r\n”
-> “cache-control: no-cache\r\n”
-> “connection: close\r\n”
-> “content-length: 0\r\n”
-> “date: Tue, 04 Aug 2015 01:44:57 GMT\r\n”
-> “server: tsa_b\r\n”
-> “set-cookie: guest_id=v1%3A143865269717898050; Domain=.twitter.com; Path=/; Expires=Thu, 03-Aug-2017 01:44:57 UTC\r\n”
-> “strict-transport-security: max-age=631138519\r\n”
-> “x-connection-hash: bb65120138825baf0e09fb4c830947c7\r\n”
-> “x-rate-limit-limit: 50\r\n”
-> “x-rate-limit-remaining: 48\r\n”
-> “x-rate-limit-reset: 1438653509\r\n”
-> “x-response-time: 8\r\n”
-> “x-tsa-request-body-time: 0\r\n”
-> "\r\n"
reading 0 bytes…
-> ""
read 0 bytes
Conn close
#<Net::HTTPBadRequest 400 Bad Request readbody=true>
File stored at {:cache_control=>“no-cache”, :connection=>“close”, :content_length=>“0”, :date=>“Tue, 04 Aug 2015 01:44:57 GMT”, :server=>“tsa_b”, :set_cookie=>“guest_id=v1%3A143865269717898050; Domain=.twitter.com; Path=/; Expires=Thu, 03-Aug-2017 01:44:57 UTC”, :strict_transport_security=>“max-age=631138519”, :x_connection_hash=>“bb65120138825baf0e09fb4c830947c7”, :x_rate_limit_limit=>“50”, :x_rate_limit_remaining=>“48”, :x_rate_limit_reset=>“1438653509”, :x_response_time=>“8”, :x_tsa_request_body_time=>“0”}


#8

pening connection to ton.twitter.com:443
opened
starting SSL for ton.twitter.com:443
SSL established
<- “POST https://ton.twitter.com/1.1/ton/bucket/ta_partner HTTP/1.1\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\nContent-Type: text/comma-separated-values\r\nContent-Length: 265\r\nX-Ton-Expires: Fri, 14 Aug 2015 02:59:59 GMT\r\nAuthorization: OAuth oauth_body_hash=“qyIWn2grhG4zlvZ2Huw3VKjCMrA%3D”, oauth_consumer_key=“YO7xjokBgBwaag4pzYFAL5e95”, oauth_nonce=“gn82sbed9zYfYXGoyVi1Wx0NSOgs17IlMAq2a2uLAOY”, oauth_signature=“itul95MRS6oUyYbUgvk1mdy2Eyk%3D”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1438657199”, oauth_token=“373535060-lV2l4fu1UduDVMWly5SZyf8HfxhGPov5DkqVP3Ci”, oauth_version=“1.0”\r\nConnection: close\r\nHost: ton.twitter.com\r\n\r\n”
<- “925e64f3a9efdd5aea2b6c931d20f681de132d2a6eafa525ccab8e7894e1c09f\n22ac83cf392cfb80cfaaca6f6eaaea8fe5a1986ccbfea73adbfe252db5672062\naf0e18a85917952b6da5b1cd4510f680a3e51451486f1c47a61200e54f90d710\n95718583af25f81a7f63e2007d3d4d17d2fb3da179a30f98a03104e999f9eed8\n\n”
-> “HTTP/1.1 400 Bad Request\r\n”
-> “cache-control: no-cache\r\n”
-> “connection: close\r\n”
-> “content-length: 0\r\n”
-> “date: Tue, 04 Aug 2015 03:00:00 GMT\r\n”
-> “server: tsa_b\r\n”
-> “set-cookie: guest_id=v1%3A143865720018604169; Domain=.twitter.com; Path=/; Expires=Thu, 03-Aug-2017 03:00:00 UTC\r\n”
-> “strict-transport-security: max-age=631138519\r\n”
-> “x-connection-hash: c71d20211cabf0c91315b9e6c4a7eac5\r\n”
-> “x-rate-limit-limit: 50\r\n”
-> “x-rate-limit-remaining: 49\r\n”
-> “x-rate-limit-reset: 1438658100\r\n”
-> “x-response-time: 10\r\n”
-> “x-tsa-request-body-time: 91\r\n”
-> "\r\n"
reading 0 bytes…
-> ""
read 0 bytes
Conn close
File stored at


#9

We have the same issue, 400 Bad request.
Neither single upload nor resumable upload work. ton_upload.rb does not work, either.


#10

One thing to note that might be causing the issue is when you supply a Content-Type: text/comma-separated-values header to the request, if the request itself doesn’t have the expected suffix it will return a 400.


#11

We had everything working very smoothly until Friday, at which point we started getting 400 codes on every request. We’re just sending the csv data through as the post body, something like:

925e64f3a9efdd5aea2b6c931d20f681de132d2a6eafa525ccab8e7894e1c09f\n22ac83cf392cfb80cfaaca6f6eaaea8fe5a1986ccbfea73adbfe252db5672062\naf0e18a85917952b6da5b1cd4510f680a3e51451486f1c47a61200e54f90d710\n95718583af25f81a7f63e2007d3d4d17d2fb3da179a30f98a03104e999f9eed8\n

So there’s not a suffix at all as far as I can tell. When using ton-upload, I was using a .csv suffixed file, but I believe that is stripped out and the body of the file is sent directly in the post request by the script.


#12

I actually just had a few requests go through successfully. I will do some more testing today to make sure things are fixed on my end now. I did not change any code. Just seems to be working now.

Thanks, @andrs.


#13

It started working for us as well.


#14

Same here. Everything’s back to normal :wink:


#15

We had made some security-related changes last week but we didn’t take into consideration some scenarios - we sorted that out so I am glad to hear that it’s all good for everyone!


#16

Found a similar (but possibly new bug) to this: Tailored Audience TON 400 Error for Resumable Upload.