Upload Image using POST form data in Python-requests

前端 未结 7 1811
醉话见心
醉话见心 2020-11-27 04:16

I\'m working with wechat APIs ... here I\'ve to upload an image to wechat\'s server using this API http://admin.wechat.com/wiki/index.php?title=Transferring_Multimedia_Files

7条回答
  •  长情又很酷
    2020-11-27 04:32

    I confronted similar issue when I wanted to post image file to a rest API from Python (Not wechat API though). The solution for me was to use 'data' parameter to post the file in binary data instead of 'files'. Requests API reference

    data = open('your_image.png','rb').read()
    r = requests.post(your_url,data=data)
    

    Hope this works for your case.

提交回复
热议问题