I have a very simple POST API in this URL: https://lookaguide.com/api/test
The api are in Laravel 5.2 and this api only return a string that says: "All is OK"
This is the code of the API:
Route::post('test', function(){
return response()->json(['All is OK']);
});
When I use this API with Postman the api return the correct information.
I'm using Alamofire 3.4, when I consume the API the 405 error appers as if the POST resquest did not exist.
This is my code:
Alamofire.request(.POST, "https://lookaguide.com/api/test", parameters: nil)
.responseJSON { response in
switch response.result {
case .Success:
print(response.request) // original URL request
print(response.response) // URL response
case .Failure(let error):
print(response.request) // original URL request
print(response.response) // URL response
}
}
Error in Xcode when print respose.response
Optional(<NSHTTPURLResponse: 0x7914a870> { URL: https://lookaguide.com/api/test } {
status code: 405, headers {
"Cache-Control" = "no-cache, private";
Connection = "Keep-Alive";
"Content-Type" = "text/html; charset=UTF-8";
Date = "Wed, 03 Aug 2016 18:24:49 GMT";
"Keep-Alive" = "timeout=3, max=30";
Server = "Apache Phusion_Passenger/4.0.10 mod_bwlimited/1.4 mod_fcgid/2.3.9";
"Transfer-Encoding" = Identity;
"X-Powered-By" = "PHP/5.6.22";
allow = POST;
} })
Any suggest?