multipart data POST using python requests: no multipart boundary was found

后端 未结 3 998
[愿得一人]
[愿得一人] 2020-12-08 19:26

I have a form-data as well as file to be sent in the same POST. For ex, {duration: 2000, file: test.wav}. I saw the many threads here on multipart/form-data posting using py

相关标签:
3条回答
  • 2020-12-08 20:03

    Taking out the Content-Type header with explicit "multipart/form-data" worked!

    0 讨论(0)
  • 2020-12-08 20:13

    To specifically add boundary add following in header :

    headers = {
        'content-type': 'multipart/form-data; boundary=ebf9f03029db4c2799ae16b5428b06bd'
    }
    
    0 讨论(0)
  • 2020-12-08 20:20

    You should NEVER set that header yourself. We set the header properly with the boundary. If you set that header, we won't and your server won't know what boundary to expect (since it is added to the header). Remove your custom Content-Type header and you'll be fine.

    0 讨论(0)
提交回复
热议问题