Sample multipart/form-data image request


I’m looking for a sample working multipart/form-data request that uploads an image

I’ve tried everything to create the request per known specs and always get this error:
System.HttpResponse[Status=Internal Server Error, StatusCode=500]
|{“errors”:[{“message”:“Internal error”,“code”:131}]}

Does Twitter not accept a Content-Type of multipart/form-data?
req.setHeader(‘Content-Type’, ‘multipart/form-data; boundary=’+boundary)

I’m guessing this because even when I put in bogus oauth credentials, I get the same error.
If I change the Content-Type to something else, then I get a 401 authentication error.


@MichaelLin7 has few twurl command examples. You could add -t argument to get request and response trace logs. For example,

twurl -H -X POST “/1.1/media/upload.json” --file “/path/to/image.jpg” --file-field “media” -t

Upload api accepts multipart/form-data content type.

closed #3