SparkPost API 抑制列表返回 "Method not allowed"

SparkPost API suppression-list returning "Method not allowed"

我正在尝试将条目插入 here

所述的黑名单

我已经使用 PHP 代码尝试了这一点,但我也在提供的网站上使用他们自己的控制台使用具有相同结果的有效 API 密钥获得了相同的响应。

这是电话:

PUT https://api.sparkpost.com/api/v1/suppression-list/email@gmail.com

这是请求:

Content-Type: application/json
Authorization: XXXXXXXXXXXXX
Content-Length: 142
{
  "transactional": false,
  "non_transactional": true,
  "description": "User requested to not receive any non-transactional emails."
}    

这是我从服务器得到的响应:

connection: keep-alive
x-apiary-transaction-id: 5638e31d13b31d0700ae2b0a
cache-control: no-cache, no-store
content-type: application/json; charset=utf-8
date: Tue, 03 Nov 2015 16:38:54 GMT
server: msys-http
content-length: 45
x-newrelic-app-data: PxQDVFVRCQITVlZRDgcFV0YdFHYaFhEHQxFSERdoYWYcShNDHVEdUlIEG1FIVgsFBFxSVg8IG0RQBBQfQFdQVAFWWlsBXVdTUVcPURNNVQMIRVI8
via: 1.1 vegur
{
  "errors": [
    {
      "message": "Method Not Allowed"
    }
  ]
}   

当您将整体添加到禁止列表时,您需要将它们 PUT 添加到 https://api.sparkpost.com/api/v1/suppression-list 并且请求的 body 需要像这样:

{
  "recipients": [
    {
      "email": "rcpt_1@example.com",
      "transactional": true,
      "description": "User requested to not receive any transactional emails."
    },
    {
      "email": "rcpt_2@example.com",
      "non_transactional": true
    }
  ]
}

此端点的 API 文档位于 https://www.sparkpost.com/api#/reference/suppression-list/bulk-insertupdate/insert-or-update-list-entries

作为旁注,您应该确保以后不要在您的问题中 post Authorization header。那是你的 API 密钥 - 我建议删除该密钥并创建一个新密钥。