Hi,
how can i execute in swift a web service that was build in java ?
the url is http://52.30.114.86:8080/mimosms/v1/user/login?username=xxxx&password=5555
The service works fine in my browser, but when i try to run in xcode i receive the message : Optional({"errors":["Request method 'POST' not supported"]})
below the code :
let url:NSURL = NSURL(string: "http:/
let session = NSURLSession.sharedSession()
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "POST"
request.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringCacheData
let paramString = "login?username=xxxx&password=5555"
request.HTTPBody = paramString.dataUsingEncoding(NSUTF8StringEncoding)
let task = session.dataTaskWithRequest(request) {
(
let data, let response, let error) in
guard let _:NSData = data, let _:NSURLResponse = response where error == nil else {
print("error")
return
}
let dataString = NSString(data: data!, encoding: NSUTF8StringEncoding)
print(dataString)
}
task.resume()
}what could be wrong in the code ?
Regards