I’ve been struggling with this for a while, and cannot figure out why my request returns a 500 error.
POST https://api.twitter.com/1.1/statuses/update_with_media.json HTTP/1.1
Authorization: OAuth oauth_consumer_key="...", oauth_nonce="...", oauth_signature="...", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1364272000", oauth_token="...", oauth_version="1.0"
Content-Type: multipart/form-data; boundary=~~~~~~b925f200d90150c3~~~~~~
Host: api.twitter.com
Content-Length: 73236
Content-Type: multipart/form-data;boundary=~~~~~~b925f200d90150c3~~~~~~
Accept-Encoding: gzip
--~~~~~~b925f200d90150c3~~~~~~
Content-Disposition: form-data; name="status"
Just a test post!
--~~~~~~b925f200d90150c3~~~~~~
Content-Type: application/octet-stream
Content-Disposition: form-data; name="media[]"; filename="my_image.jpg"
--~~~~~~b925f200d90150c3~~~~~~
… followed by the binary data for the image being posted. According to your examples I don’t see a thing wrong.
kurrik
#2
I think your request is a bit off. It looks like you have an extra boundary line between the media headers and the image data. You also have an extra space between headers in the first and third blocks. Finally, there are two Content-Type headers in the first block.
Here’s a request which succeeded:
POST /1.1/statuses/update_with_media.json HTTP/1.1
Host: api.twitter.com
User-Agent: Go http package
Content-Length: 15532
Authorization: OAuth …foo…
Content-Type: multipart/form-data;boundary=83f11d350617544d8d7765917f60b01f19fc9487cc0221e1048e4b3c00e4
Accept-Encoding: gzip
–83f11d350617544d8d7765917f60b01f19fc9487cc0221e1048e4b3c00e4
Content-Disposition: form-data; name=“status”
Hello 2013-03-26 09:41:21.117478 -0700 PDT!
–83f11d350617544d8d7765917f60b01f19fc9487cc0221e1048e4b3c00e4
Content-Disposition: form-data; name=“media”; filename=“media.png”
Content-Type: application/octet-stream
�PNG
IHDRM��ie�
�iCCPICC ProfileH���aPTY��{��ɱ�9�$�$
kurrik
#3
I should follow up and say that the end of the request looks like this:
...
)���?��H�o�IEND�B`�
--83f11d350617544d8d7765917f60b01f19fc9487cc0221e1048e4b3c00e4--
ghghgfhgfhghhhhhhhhhhhhhhh