来自本地主机的带有python 27的Google App Engine应用程序尝试通过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": "[email protected]",
      "to": [
        {
        "email": "[email protected]",
        }
        ]
    }
}

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


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

最佳答案

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



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

关于python - 来自带有Google App Engine的urlfetch的mandrill的ValidationError,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16260022/

10-11 22:07