1

来自本地主机的带有 python 27 的 Google 应用引擎应用程序试图通过 mandrill 的服务发送邮件。

我收到一个:

{"status":"error","code":-1,"name":"ValidationError","message":"You must specify a key value"}

从谷歌应用引擎中的这段代码:

my_payload = 
{
 "key": mandrill_key,
 "message": {
      "html": "<p>Example HTML content</p>",
      "subject": "prueba redquintal",
      "from_email": "MY_EMAIL@XXX.com",
      "to": [
        {
        "email": "SOME_EMAIL@gmail.com",
        }
        ]
    }
}

try:
    content = urlfetch.fetch(mandrill_url, method=urlfetch.POST, headers={'Content-Type': 'application/json'}, payload=my_payload)
    if content.status_code == 200:

        # some_code

    else:

        # some_code


except urlfetch.DownloadError:

    # some_code

关于可能是什么问题的任何想法?

4

1 回答 1

2

我认为有效载荷应该是一个字符串

import json
content = urlfetch.fetch(mandrill_url, method=urlfetch.POST, headers={'Content-Type': 'application/json'}, payload=json.dumps(my_payload))
于 2013-04-28T06:14:02.457 回答