I have this body to make a POST
to the backend
'{"token":"xxxx", "extra_information": {"expires_in": xxxx, "refresh_token": "xxx", "user_id": "user_uuid", "token_type": "Bearer"}}'
The parameters that are with "xxxx" will come from an integration, so I made a function for that.
func sendAuth() {
if let url = NSURL(string: "https://xxxxxxxxxxxx"){
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
let token = AccessToken?()
let params = ["token" : (token?.tokenString)!, "refresh_token" : (token?.refreshToken)!,"expires_in" : (token?.expirationDate)!, "user_id" : "uber_uuid" , "token_type" : "Bearer"] as Dictionary <String,AnyObject>
let httpData = NSKeyedArchiver.archivedDataWithRootObject(params)
request.HTTPBody = httpData
let session = ServicesUtils.BaseSessionManager()
session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
var strData = NSString(data: data, encoding: NSUTF8StringEncoding)
print("\(strData)")
}).resume()
After you have made the parameters correctly, the xcode
is displaying the following error:
"Can not convert value of type 'NSURLResponse to expected argument type' NSData"
Can anyone help me with this problem?
I think it's in the line let httpData = NSKeyedArchiver.archivedDataWithRootObject(params)
that the error starts but I do not know how to do other syntax to work the code.