我正在使用SoftLayer API SoftLayer_Network_Message_Delivery_Email_Sendgrid
向我的Slack频道发送电子邮件。
我有时会安静地获取API响应代码500。我发布了下面的错误消息
{"错误":"超出最高积分","代码":" SoftLayer_Exception_Network_Message_Delivery_Email_Sendgrid_Api_Error"} 500
我使用sendEmail的代码如下:
curl -w %{http_code} -v -H "Content-Type: application/json" -d '{"parameters": [{ "body": "body","containsHtml": false,"from": "no-reply@noreply.com","subject": "Problem with system backup!", "to": "<EmailID/Slack ID>"}]}' 'https://<username>:<API Key>@api.service.softlayer.com/rest/v3/SoftLayer_Network_Message_Delivery_Email_Sendgrid/57084/sendEmail.json'
此外,我想了解上面的URL中的57084是什么
答案 0 :(得分:1)
57084数据是电子邮件投放ID,默认情况下是在您的帐户中创建新电子邮件投放时生成的。
此ID是在请求的必需标头中发送的SoftLayer_Network_Message_Delivery_Email_SendgridInitParameters。
有关详细信息,请参阅以下文档: https://softlayer.github.io/reference/services/SoftLayer_Network_Message_Delivery_Email_Sendgrid/sendEmail/
要获取与您的SL帐户相关联的电子邮件递送ID,您可以使用此卷曲示例:
curl -k "https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkMessageDeliveryAccounts.json" | python -mjson.tool
您将收到如下回复:
[
{
"accountId": 111111,
"createDate": "2015-10-23T10:25:12-06:00",
"id": 57084,
"modifyDate": null,
"password": "sdfsdfsd",
"typeId": 21,
"username": "user@yahoo.com",
"vendorId": 1,
"emailAddress": "test@yahoo.com",
"smtpAccess": "1"
}
]
您收到的错误是因为您的SendGrid帐户中没有足够的信用额度。
要获得您的信用帐户,您可以使用此curl示例。信息直接来自SendGrid服务器:
curl -k "https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Network_Message_Delivery_Email_Sendgrid/57084/getAccountOverview.json" | python -mjson.tool
如果您想获得有关SendGrid帐户和信用额的更多信息,可以访问其页面。
要获取您的SendGrid帐户的网址,您可以使用此curl命令:
curl -k "https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Network_Message_Delivery_Email_Sendgrid/57084/getVendorPortalUrl.json" | python -mjson.tool