But once I come to ask for help from you. I'm developing an application in Swift using web service writing in java hosted at Amazon AWS.
When I try to make a registration via post the registration is not performed. The error that returns me is as follows
FAILURE: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
FAILURE
registration code snippet
Alamofire.request(.POST, url, parameters: usuario, encoding: .JSON, headers: nil).responseJSON(completionHandler: { (response) in
if response.result.isSuccess{
//self.geraAlerta("Sucesso", mensagem: "Cadastro realizado com Sucesso")
self.populaUsuario()
self.performSegueWithIdentifier("cadastroTelaPrincipal", sender: self)
}else{
print(response.description,"<-------")
self.geraAlerta("Falha", mensagem: "Não foi possível completar o cadastro, tente novamente mais tarde!")
}
self.btnCadastrar.userInteractionEnabled = true
print(response.result)
print(response.result.value)
})
Code in web service
@POST
@Path("/inserir")
@Consumes(MediaType.APPLICATION_JSON)
public void insereUsuario(Usuario usuario) {
if (usuario != null) {
try {
usuario.setFotoByte(Util.converteToByte(usuario.getFoto()));
usuario.setDataCadastro(new Date());
new UsuarioDAO().inseirUsuario(usuario);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Can someone please tell me how to solve this problem?
If I try to access the url directly through the browser it returns me 405