Question

Google app engine app with python 27 from localhost trying to send mail through mandrill's service.

I'm receiving a :

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

from this code in google app engine:

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

Any idea on what's could be the problem?

Was it helpful?

Solution

I think the payload should be a string

such as

import json
content = urlfetch.fetch(mandrill_url, method=urlfetch.POST, headers={'Content-Type': 'application/json'}, payload=json.dumps(my_payload))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top