Hi.

I finally managed to get my image update code working, too. In case
someone still has problems here are my findings / observations:

* There only must be one blank line between HTTP request header and
body (java jersey created two).
* Newlines in request header and multipart headers must be CR/LF (both
characters).
* It is NOT important that the following headers exist - you CAN skip
them: User-Agent, Content-Length. Expect
* The blank before "boundary" in "Content-Type: multipart/form-data;
boundary=..." is NOT important.
* But it IS important that you mention the boundary in the content
type header (jersey skipped it).
* Each part of the multipart content begins with "--" + boundary
* The end of the last part is marked with "--" + boundary + "--"
* It is important that the header of the file part also contains a
filename.

Taken together the working request looks like this
("working" of course only after you have to inserted real
authentication and binary data).

POST https://twitter.com/account/update_profile_background_image.xml
Authorization: Basic your_auth_string
Content-Type: multipart/form-data; boundary=some_unique_string

--some_unique_string
Content-Disposition: form-data; name="image"; filename="image.gif"
Content-Type: image/gif

your binary data goes here
--some_unique_string
Content-Disposition: form-data; name="tile"
Content-Type: text/plain

true
--some_unique_string--

Thanks to josh (he sent me his findings via private mail).
Thanks to David, too (he wrote about the problem with two blank lines
between header and body in
http://groups.google.com/group/twitter-development-talk/browse_thread/thread/4fe78c5c7fb5cbdf/59f9ef7c8f745f93

Mitchel

Reply via email to