0
Swift 3中的Alamofire 4請求總是失敗,並顯示500個狀態碼。我嘗試了Postman並且工作!使用django API和Alamofire請求失敗
看我的代碼:
func newUser(user: User) {
var urlRequest = URLRequest(url: URL(string: url + "/register")!)
urlRequest.httpMethod = "POST"
let parameters: Parameters = [
"username": "\(user.name!)",
"email": "\(user.email!)",
"password": "(Kh=CE)4r)PC4}f?",
"profile": [
"status": 0,
"level": 0,
"facebook_id": "\(user.fbId!)",
"facebook_token": "000",
"push_device_token": "000",
"photo": "\(user.photoUrl!)"
]
]
let headers: HTTPHeaders = ["Content-Type": "application/json"]
Alamofire.request(url+"/register", method: .post, parameters: parameters, encoding: JSONEncoding(options: []), headers: headers).response { response in
debugPrint(response)
print(response)
}
}
任何人都可以幫我嗎?