Eu tenho um formulario que deve ser preenchido no aplicativo e enviado ao web service para cadastrar um novo usuário.
Como poderia enviar estes dados para o web service usando AFNetworking 2.0?
Tentei usar o código abaixo, mas retornou um erro:
NSDictionary *params = @{@"id" : idCadastro.text,
@"nome" : nomeCadastro.text,
@"email" : emailCadastro.text,
@"cidade" : localidadeCadastro.text,
@"passe" : senhaCadastro.text
};
NSString* HOST_URL = @"http://10.1.1.6/advphp/cad_adv_0.php?";
AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager];
[operationManager POST: HOST_URL parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject){
// Enter what happens here if successsful.
NSLog(@"Cadastrado");
}failure:^(AFHTTPRequestOperation *operation, NSError *error){
// Enter what happens here if failure happens
NSLog(@"Não Cadastrado. Erro:\n%@",error);
}
];
E abaixo a mensagem de erro que aparece:
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x7969de10 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}