Open tonyblank opened 10 years ago
Can you provide more context, how about a code sample that demonstrates the issue?
For e.g. POST, OAuth1Session.request()
does
req_kwargs['headers'].setdefault('Content-Type', FORM_URLENCODED)
.
This seems to override the proper "multipart/form-data" content type which PreparedRequest.prepare_body()
gets from self._encode_files()
.
Overriding it manually using headers
parameter for session.post()
won't work since the content-type field needs to contain the boundary information which the rauth user doesn't know.
I workarounded this locally by making this modification:
entity_method = method.upper() in ENTITY_METHODS
- if entity_method:
+ if entity_method and not req_kwargs.get('files', None):
req_kwargs['headers'].setdefault('Content-Type', FORM_URLENCODED)
@anssih mind submitting a patch for that?
+1
This stumped me for a couple of hours when trying to upload to twitter's media/upload endpoint.
Same fix worked.
@davidkhess patches welcome. :)
Ok, you guilted me into it. :-)
I'm trying to make a multipart/form-data POST and can't figure out how to set the content-type to multipart/form-data. It's 'content-type': 'application/x-www-form-urlencoded'. - That's strange to me because I see the boundary in the body..
When I manually set the content-type header to multipart/form-data, then there's no boundary defined...