my company and I are working on a iOS Project, and we get stacked in this issue. We are trying to make a POST request to our API, but all we are getting is a success code but with a reponse of type:
SUCCESS: { detail = "Authentication credentials were not provided."; }
Here is our code:
@IBAction func accept(_ sender: Any) {
var comm,cat,dist : String!
comm = observationstwee.text!
print(comm)
let catd = 7
cat = String(catd)
print(cat)
dist = distancetwee.text!
print(dist)
let parameters: Parameters = [
"comment":comm,
"category":cat,
"distance":dist,
"timestamp":time
]
let headers: HTTPHeaders = ["Authorization": "Token \(token!)"]
print(headers.debugDescription)
Alamofire.request("https://llegoelbigotes.ubiqme.es/api/new-travel",parameters: parameters, headers: headers).responseJSON {response in switch(response.result) {
case .success(_):
print(response)
print("Correct Travel")
//changeViewController(storyboard_name: "Main", viewcontroller_name: "tabBarController", context: self)
break
case .failure(_):
print("FAILURE")
}
}
}
Thanks for the help we are working with Alamofire 4.5 and iOS 11.2