尝试使用 API 将联系人添加到我的发送网格时出现 405 错误

问题描述 投票:0回答:1

我正在尝试使用 API 将联系人添加到我的 sendgrid。

const addContactToList = async (email, listId) => {
  try {
    await axios.post(
      `https://api.sendgrid.com/v3/marketing/contacts`,
      {
        list_ids: [listId],
        contacts: [
          {
            email: email,
          },
        ],
      },
      {
        headers: {
          Authorization: `Bearer ${SENDGRID_API_KEY}`,
          'Content-Type': 'application/json',
        },
      }
    )
    console.log('Works')
  } catch (error) {
    console.log(error.message)
  }
}

但我收到错误 405 作为回报。我已授予此特定 API 密钥完全权限。

为什么 API 会报 405 错误?

api sendgrid http-status-code-405
1个回答
0
投票

要添加或更新联系人,请求方法必须是“PUT”。

https://docs.sendgrid.com/api-reference/contacts/add-or-update-a-contact

© www.soinside.com 2019 - 2024. All rights reserved.