【发布时间】:2020-01-24 10:30:49
【问题描述】:
我正在尝试通过 httparty gem 使用 GET 请求从 SlackAPI 获取有关特定用户的信息。从 curl 它运行良好
curl --data "token=SLACK_TOKEN&email=user@example.com" https://slack.com/api/users.lookupByEmail
但是我下面的代码似乎被破坏了,因为我收到了一个错误{"ok":false,"error":"users_not_found"}
module Slack
class GetUserId
def call
response = HTTParty.get("https://slack.com/api/users.lookupByEmail", payload: payload, headers: headers)
end
def headers
{
'Content-Type' => 'application/json',
'Authorization' => 'Bearer SLACK_TOKEN'
}
end
def payload
{
email: "user@example.com"
}.to_json
end
end
end
【问题讨论】: