Created
September 13, 2012 14:39
-
-
Save fawkeswei/3714727 to your computer and use it in GitHub Desktop.
How to post json data using AFNetworking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL *url = [NSURL URLWithString:@"http://someurl.com/"]; | |
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; | |
// don't forget to set parameterEncoding! | |
httpClient.parameterEncoding = AFJSONParameterEncoding; | |
NSDictionary *params = @{@"key" : @"value"}; | |
NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"" parameters:params]; | |
AFHTTPRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:nil failure:nil]; | |
[operation start]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment