ios - AFNetworking JSON RESTful Service parameters -


i'm new using afnetworking , there i'm missing calling api.

here code (most of part af* example) :

afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; manager.securitypolicy.allowinvalidcertificates = yes; afjsonrequestserializer *reqserializer = [afjsonrequestserializer serializer]; [reqserializer setvalue:@"application/json" forhttpheaderfield:@"content-type"]; [reqserializer setvalue:@"application/json" forhttpheaderfield:@"accept"]; manager.requestserializer = reqserializer;  afjsonresponseserializer *resserializer = [afjsonresponseserializer serializer]; [resserializer setreadingoptions:nsjsonreadingallowfragments | nsjsonreadingmutablecontainers]; resserializer.acceptablecontenttypes = [nsset setwithobjects:@"text/html", @"application/json", nil]; manager.responseserializer = resserializer;  nsstring *urlstring =[nsstring stringwithformat:@"%@/users/userlogin", baseurlstring]; nsdictionary *params = @{                          @"username": self.txtuser.text,                          @"password": self.txtpass.text                          };  [manager post:urlstring parameters:params success:^(afhttprequestoperation *operation, id responseobject) {     nslog(@"json: %@", responseobject); } failure:^(afhttprequestoperation *operation, nserror *error) {     nslog(@"error: %@", error); }]; 

calling code url is: http://localhost:8000/users/userlogin

but right parameters should be: http://localhost:8000/users/userlogin/john/mypass

finally i'm getting "request failed: not found (404)"

the dirty workaround test afnetworking:

nsstring *urlstring = [nsstring stringwithformat:@"%@/users/userlogin/%@/%@", baseurlstring, self.txtuser.text, self.txtpass.text]; 

and worked :p

any idea wrong ?

thank !

make sure path resource should right. 404 error generated when url path not valid or server couldn't find requested resource. , if passing post paramater server should handle post parameter only. url should 'http://localhost:8000/users/userlogin/'


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -