Stumped by a 500 internal server error with statuses/update_with_media


I have an update_with_media post that seems correct to me, but only returns 500 internal errors (with code 131) from Twitter.

I have reviewed other similar posts here and believe I am covering all my bases:

  • I am only signing with the oauth_ values (deliberatly adding “status” indeed gives unauthorized errors)

  • I believe I am using blank lines properly, one before all values. I used \r\n for line ends.

  • I am using Content-Type: application/octet-stream, and am appending the image bytes directly.

  • My image is a tiny test .png that seems valid, views fine in an image viewer

  • My Content-Length seems correct, it matches the exact total byte count that I appended to the request.

You can see my POST below, unfortunately I had to remove the image bytes. I also am using http: vs the normal https: to allow capture in Fiddler.

Could I also email you my actual post somehow? Also, if I send you my (tiny) test image, can you send me a sample update_with_media POST that I can compare to?

Is it possible some of the extra headers are messing things up, e.g. Twitter session cookies?

POST /1.1/statuses/update_with_media.json HTTP/1.1
Referer: app:/TestUpload.swf
Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8, text/css, image/png, image/jpeg, image/gif;q=0.8, application/x-shockwave-flash, video/mp4;q=0.9, flv-application/octet-stream;q=0.8, video/x-flv;q=0.7, audio/mp4, application/futuresplash, */*;q=0.5
x-flash-version: 11,7,700,202
Content-Type: multipart/form-data; boundary=-------------------------1fc9651dad39
Authorization: OAuth oauth_consumer_key="yTDi5gns5GbySarDohZ3kg",oauth_token="409825688-1WUm0dG6TqL9mL2UBPltGz4IRvMlBZuhSctfnPUl",oauth_nonce="823597213714902271563",oauth_timestamp="1371490227",oauth_signature_method="HMAC-SHA1",oauth_version="1.0",oauth_signature="Zle%2BMqD8QGD4qH7r9Ix9bByhJeE%3D"
Content-Length: 498
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows; U; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) AdobeAIR/3.7
Connection: Keep-Alive
Pragma: no-cache
Cookie: lang=en; guest_id=v1%3A134211872198649202; twll=l%3D1371258916; remember_checked=0; __utma=43838368.1963420972.1342953168.1342953168.1342953168.1; __utmv=43838368.lang%3A%20en; remember_checked_on=0; _twitter_sess=BAh7CDoMY3NyZl9pZCIlZDk5MjIzYjA4MzIyYzEyYzczZTRmN2JlMDgzYzZm%250AMjI6D2NyZWF0ZWRfYXRsKwgc1S9TPwE6B2lkIiUxNTU2ZWRmOTJmNTExNzgy%250AZTU1ZTFlNTY5MzRhZWI3OQ%253D%253D--45021f756185589edba6561b54c07e6789215300

Content-Disposition: form-data; name="media[]"; filename="smallImage.png"
Content-Type: application/octet-stream

<image bytes removed>
Content-Disposition: form-data; name="status"

a test tweet with an uploaded file


I found my problem, it was ultimately trivial: I needed a – suffix for the final boundary.