AFNetworking 2.0 Send Post Request with URL Parameters

Viewed 15076

How do I send a POST request with AFNetworking 2.0 with all the parameters in the URL like such:

http://www.myserver.com?api_key=something&lat=2.4&radius=100

Right now I have:

NSString* query = @"http://example.com?name=param&date=param";
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{};
[manager POST:query parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

But it's not working, I get this error back:

Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: bad request (400)

6 Answers
Related