Question

I'm using python 2.7 and requests This is taken from mailgun's docs :

def send_inline_image():
    return requests.post(
        "https://api.mailgun.net/v2/samples.mailgun.org/messages",
        auth=("api", "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"),
        files=MultiDict([("inline", open("files/test.jpg"))]),
        data={"from": "Excited User <me@samples.mailgun.org>",
              "to": "sergeyo@profista.com",
              "subject": "Hello",
              "text": "Testing some Mailgun awesomness!",
              "html": '<html>Inline image here: <img src="cid:test.jpg"></html>'})

When trying to send the attchments as described I get the following error:

    files=MultiDict([("inline", open("embeddedImages/bg.png"))])
  File "build\bdist.win32\egg\requests\api.py", line 87, in post
  File "build\bdist.win32\egg\requests\safe_mode.py", line 37, in wrapped
  File "build\bdist.win32\egg\requests\api.py", line 42, in request
  File "build\bdist.win32\egg\requests\sessions.py", line 230, in request
  File "build\bdist.win32\egg\requests\models.py", line 507, in send
  File "build\bdist.win32\egg\requests\models.py", line 366, in _encode_files
  File "build\bdist.win32\egg\requests\packages\urllib3\filepost.py", line 80, i
n encode_multipart_formdata
TypeError: 'list' does not have the buffer interface

Any ideas?

Regards, Omer.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top