Search code examples
postmethodsparameter-passingafnetworkingraw-data

how to post parameter like {"register_id":"3"} in AFNetworking


i tried it but didn't work in AFNetworking only showing parameters error but i used postman to check and when i send data via key and value it showing error but from raw data i send {"register_id":"3"} then it will show me data so how to post parameter like this in AFNetworking.

using This Link

http://www.icubemedia.net/visitorbook/display_all.php

is any one can help me for that how to post that data

log error is:

2015-06-19 14:05:08.078 DemoAFNetworking[72771:1160924] {"msg":"parameter missing!"}


Solution

  • Check this example on how to do a GET with simple parameter with AFNetworking 2.0:

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    NSDictionary *parameters = @{@"foo": @"bar"};
    
    [manager GET:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"JSON: %@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];
    

    EDIT 1: added JSON serializer ;)