POST statuses/update_with_media error 500


#1

I’m trying to use POST statuses/update_with_media with no success, I generate oauth signature only with oauth_* parameters (no status or other parameters in signature) and generate request as documented (or so I think). This is a sample request, I tryed adding boundary bytes at the end of request body and not adding them with same result:

POST https://api.twitter.com/1.1/statuses/update_with_media.json HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------8d12d114002efcb
Authorization: OAuth oauth_consumer_key=“XXXXX”, oauth_nonce=“XXXXXXX”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1398253455”, oauth_token=“XXXXXX”, oauth_signature=“xxxxxx”, oauth_version="1.0"
Host: api.twitter.com
Content-Length: 33443
Connection: Keep-Alive

-----------------------------8d12d114002efcb
Content-Disposition: form-data; name=“status”

tweee
-----------------------------8d12d114002efcb
Content-Type: application/octet-stream
Content-Disposition: form-data; name=“media[]”; filename="001.jpg"
����

I get a response with a 500 server error and this content, not very descriptive:

{“errors”:[{“message”:“Internal error”,“code”:131}]}

Any ideas?


#2

After some days testing I manage to do a succesfull request with an external library Spring.Social. Comparing requests byte by byte my request and Spring.Social request are exactly the same except for oauth parameters (different tokens and they don’t seem to have parameters in alfabethical order) and this line which I don’t seem to get rid off: Connection: Keep-Alive (at most, I can change by Connection: Close).

As I sayed before, I only include oauth_* parameters in signature generation. My oauth signature generation works ok in all other requests (not multipart)

This is my fail request:

POST https://api.twitter.com/1.1/statuses/update_with_media.json HTTP/1.1
Accept: application/json
Content-Type: multipart/form-data;boundary=---------------------------8d131035a8b79e1
Authorization: OAuth oauth_consumer_key=“XXX”, oauth_nonce=“XXX”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1398687291”, oauth_token=“XXXX”, oauth_signature=“XXXX%3D”, oauth_version="1.0"
Host: api.twitter.com
Content-Length: 13102
Connection: Keep-Alive

-----------------------------8d131035a8b79e1
Content-Disposition: form-data; name="status"
Content-Type: text/plain;charset=ISO-8859-1

twee
-----------------------------8d131035a8b79e1
Content-Disposition: form-data; name=“media”; filename="JMT1 Original.png"
Content-Type: image/png

FILE DATA HERE
-----------------------------8d131035a8b79e1

And this is Spring.Social succesful request:

POST https://api.twitter.com/1.1/statuses/update_with_media.json HTTP/1.1
Accept: application/json
Content-Type: multipart/form-data;boundary=LcwnoByCVlOAtSpHw9s8bfB5uQF1K4SLSBWu2S
Authorization: OAuth oauth_consumer_key=“XXXX”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1398681810”, oauth_nonce=“XXXXXX”, oauth_version=“1.0”, oauth_token=“XXXX”, oauth_signature="XXXX%3D"
Host: api.twitter.com
Content-Length: 13092

–LcwnoByCVlOAtSpHw9s8bfB5uQF1K4SLSBWu2S
Content-Disposition: form-data; name="status"
Content-Type: text/plain;charset=ISO-8859-1

twee
–LcwnoByCVlOAtSpHw9s8bfB5uQF1K4SLSBWu2S
Content-Disposition: form-data; name=“media”; filename="JMT1 Original.png"
Content-Type: image/png

FILE DATA HERE
–LcwnoByCVlOAtSpHw9s8bfB5uQF1K4SLSBWu2S

Help please??