I am new to both iOS and AFNetworking. I'm used to Titanium and the very simple way of posting and getting data with a model similar to xhr in Javascript. I send a Post request to my server and get back JSON. It works flawlessly in Titanium, but I'm having a heck of a time getting it to work natively.
After doing some looking into the backend of Titanium, it appears that they are using ASI, which I found interesting. Now it seems like AFNetworking is the alternative, since ASI is no longer being updated. When I send the request below, however, it gets a text/html response and not a JSON response. I'm guessing it is because of the parameters and how they are being sent.
On a different StackOverflow question the person needed to provide standard post variables to the server and the server responded with JSON which is exactly what I need to do. The suggestion was to set the "parameterEncoding to AFFormURLParameterEncoding in your AFHTTPClient", but I don't know how to do that. If anyone can help me solve this issue I would be eternally grateful. I can provide the actual post address and dummy user/pass if that helps anyone figure this out.
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"username": @"dummyusername",@"password":@"dummypassword"};
NSString *URLString = @"https://www.webaddress.com/index.php?ACT=71";
[manager POST:URLString parameters:parameters constructingBodyWithBlock:^( id<AFMultipartFormData> parameters ){} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];