我能够在终端中运行curl语句并接收数据,因此现在我想使用Alamofire将其实现到我的iOS应用程序中: Estimote Rest API for GET devices
curl -X GET 'https://cloud.estimote.com/v3/devices' -u YOUR_SDK_APP_ID:YOUR_SDK_APP_TOKEN -H "Accept: application/json"
我尝试使用Swift进行以下操作,但是此代码返回关于授权的401错误。我有信心输入正确的凭据,但是我相信API不一定会考虑应用程序ID和令牌作为用户名/密码。
func getDevices(){
Alamofire.request("https://cloud.estimote.com/v3/devices", method: .get, parameters: nil, encoding: URLEncoding.default).authenticate(user: "luvbirds-iie", password: "xxx").response { response in
print(response)
}
}