Harry
Harry

Reputation: 3391

Convert CURL Request to AFNetworking Request

I would like to use the following curl request in AFNetworking 2.0. Any ideas how I would go about this?

curl --request POST -d "login=remitest&password=password&api_version=3" https://8tracks.com/sessions.json

Upvotes: 0

Views: 1017

Answers (1)

Luca Iaco
Luca Iaco

Reputation: 3457

Try this:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                        @"remitest", @"login",
                        @"password", @"password",
                        @3, @"api_version",
                        nil];
[manager POST:@"https://8tracks.com/sessions.json" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
    // do your stuff
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    // fail cases
}];

Hope it helps

Upvotes: 2

Related Questions