Slack API returns invalid_email 有效电子邮件地址错误
Slack API returns invalid_email error for valid email address
我正在向 未记录的 API users.admin.invite
发送 API 请求,以编程方式邀请新团队成员加入组织。
但是每次我发送请求,都会导致错误invalid_email
。
这很奇怪,因为如果我从 https://{myorg}.slack.com/admin/invites 发出相同的请求,它就会工作。
我已经设法获得了再次未记录客户端范围令牌,这是执行此操作所必需的。我已经将内容类型更改为 multipart/form-data
,这似乎是必需的。但是还是不行..
相关代码如下所示
const options = {
host: 'myOrg.slack.com',
path: `/api/users.admin.invite`,
method: 'POST',
headers: {
'Authorization': `Bearer ${config.slackAuthToken}`,
'Content-Type': 'multipart/form-data',
'Accept-Language': 'cs,en-GB;q=0.9,en;q=0.8',
'Accept': 'application/json',
'Cache-Control': 'no-cache'
},
formData: {
"email": event.email,
"first_name": event.firstName,
"last_name": event.lastName,
"real_name": `${event.firstName} ${event.lastName}`,
"set_active": true,
"resend": true, // Resend the invitation email if the user has already been invited and the email was sent some time ago
}
https.request(options) // simplified
未记录的 API 方法 admin.users.invite
的一个已知错误是某些电子邮件无法正常工作(文档中也提到了)。恐怕你对此无能为力。
更新
问题是请求必须作为 application/x-www-form-urlencoded
发送
我正在向 未记录的 API users.admin.invite
发送 API 请求,以编程方式邀请新团队成员加入组织。
但是每次我发送请求,都会导致错误invalid_email
。
这很奇怪,因为如果我从 https://{myorg}.slack.com/admin/invites 发出相同的请求,它就会工作。
我已经设法获得了再次未记录客户端范围令牌,这是执行此操作所必需的。我已经将内容类型更改为 multipart/form-data
,这似乎是必需的。但是还是不行..
相关代码如下所示
const options = {
host: 'myOrg.slack.com',
path: `/api/users.admin.invite`,
method: 'POST',
headers: {
'Authorization': `Bearer ${config.slackAuthToken}`,
'Content-Type': 'multipart/form-data',
'Accept-Language': 'cs,en-GB;q=0.9,en;q=0.8',
'Accept': 'application/json',
'Cache-Control': 'no-cache'
},
formData: {
"email": event.email,
"first_name": event.firstName,
"last_name": event.lastName,
"real_name": `${event.firstName} ${event.lastName}`,
"set_active": true,
"resend": true, // Resend the invitation email if the user has already been invited and the email was sent some time ago
}
https.request(options) // simplified
未记录的 API 方法 admin.users.invite
的一个已知错误是某些电子邮件无法正常工作(文档中也提到了)。恐怕你对此无能为力。
更新
问题是请求必须作为 application/x-www-form-urlencoded