Wednesday, 15 July 2015

ios - AFNetworking sends Get instead of POST -



ios - AFNetworking sends Get instead of POST -

-(void)uploaduserimagewithuiimage:(uiimage *)image { uiimage *imagetanya = [uiimage imagenamed:@"1.jpg"]; afhttprequestoperationmanager *m = [[afhttprequestoperationmanager alloc] initwithbaseurl:[nsurl urlwithstring:@"http://www.xxxxxxxx.com/yyyyyy/filesservice.svc/"]]; nsdata *imagedata = uiimagejpegrepresentation(imagetanya, 0.5); afhttprequestoperation *op = [m post:@"uploadfile" parameters:nil constructingbodywithblock:^(id<afmultipartformdata> formdata) { //do not set image within parameters dictionary did, append it! [formdata appendpartwithfiledata:imagedata name:@"1" filename:@"1.jpg" mimetype:@"image/jpeg"]; } success:^(afhttprequestoperation *operation, id responseobject) { nslog(@"success: %@ ***** %@ **** %@", operation.responsestring, responseobject, operation.request.url.absolutestring); } failure:^(afhttprequestoperation *operation, nserror *error) { nslog(@"error: %@ ***** %@", operation.responsestring, error); }]; [op start]; }

while sending request post changed because afnetworking send wrong path when server redirect method has changed wrong path : "http://www.xxxxxxxx.com/uploadfile http/1.1" when have created new project works fine in project gives me error -xcode version 5.1 - afnetworking 2.0

your request handled foundation url loading system, , not afnetworking issue.

you should delete line, since post:… method you're calling enqueues operation:

[op start];

check type of redirect server sending. if it's sending http 303, rfc 2616 mandates request type should changed get. should sending http 307. see 3xx redirection , create sure you're using right status code.

ios iphone objective-c afnetworking

No comments:

Post a Comment