2014-06-14 61 views
0

我试图通过Mandrill API发送一封电子邮件,但它与我提供的密钥发生错误。以下是我在卷曲请求中包含的text.json文件。Mandrill卷曲请求返回无效的密钥错误

{ 
'key' : 'MyActualKey', 
'message': { 
    'html': '<p>Example HTML content</p>', 
    'text': 'Example text content', 
    'subject': 'example subject', 
    'from_email': '[email protected]', 
    'from_name': 'Test', 
    'to': [ 
     { 
      'email': '[email protected]', 
      'name': 'Eric Clapton', 
      'type': 'to' 
     } 
    ], 
    'headers': { 
     'Reply-To': '[email protected]' 
    }, 
    'merge': True, 
    'tags': [ 
     'Mandrill Test' 
    ] 
}, 
'ip_pool': 'Main Pool' 
} 

然后我执行这个curl命令:

curl -X POST -H "Content-Type: application/json" --data @test.json https://mandrillapp.com/api/1.0/messages/send.json -v

在这个输出,在最后一行显示的错误而导致:

* Adding handle: conn: 0x7fd922803a00 
* Adding handle: send: 0 
* Adding handle: recv: 0 
* Curl_addHandleToPipeline: length: 1 
* - Conn 0 (0x7fd922803a00) send_pipe: 1, recv_pipe: 0 
* About to connect() to mandrillapp.com port 443 (#0) 
* Trying 54.221.22.61... 
* Connected to mandrillapp.com (54.221.22.61) port 443 (#0) 
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 
* Server certificate: mandrillapp.com 
* Server certificate: Thawte SSL CA 
* Server certificate: thawte Primary Root CA 
* Server certificate: Thawte Premium Server CA 
> POST /api/1.0/messages/send.json HTTP/1.1 
> User-Agent: curl/7.30.0 
> Host: mandrillapp.com 
> Accept: */* 
> Content-Type: application/json 
> Content-Length: 501 
> 
* upload completely sent off: 501 out of 501 bytes 
< HTTP/1.1 500 Internal Server Error 
* Server nginx/1.6.0 is not blacklisted 
< Server: nginx/1.6.0 
< Date: Sat, 14 Jun 2014 23:46:44 GMT 
< Content-Type: application/json; charset=utf-8 
< Transfer-Encoding: chunked 
< Connection: keep-alive 
< X-Powered-By: PHP/5.3.10-1ubuntu3.11 
< Access-Control-Allow-Origin: * 
< Access-Control-Allow-Methods: POST, GET, OPTIONS 
< Access-Control-Allow-Headers: Content-Type 
< Access-Control-Allow-Credentials: false 
< 
* Connection #0 to host mandrillapp.com left intact 
{"status":"error","code":-1,"name":"ValidationError","message":"You must specify a key value"} 

通知的最后一行怎么说'指定一个关键值“ - 同样,这是Mandrill控制面板的确切关键。我甚至产生了一些,他们都失败了。

回答

1

试图去改变它变成一个有效的JSON,并看看是否有帮助:

  1. 改变所有单引号到双引号
  2. 变化的“合并”,从“真”的价值为小写“真”。
+1

工作 - 谢谢! – Anconia

+0

有类似的问题。它不喜欢单引号的类型(我猜是vs撇号),所以把''改为' – isick