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??