0xSina
0xSina

Reputation: 21553

Bug in NSURLRequest or AFNetworking?

Not sure if this is a bug or I am missing something, most likely latter. My AFHTTPClient's base url is:

#define kBaseURL @"http://localhost:4567/api/"
self.client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:kBaseURL]];

When I make a request to, for example '/games', it actually sends the request to http://localhost:4567/games ignoring the API part.

Upvotes: 0

Views: 1182

Answers (2)

Keith Smiley
Keith Smiley

Reputation: 63903

The AFHTTPClient.h file has tons of comments about exactly how to use /s to make sure everything fits together correctly. Check it out on github

Upvotes: 1

Michael Dautermann
Michael Dautermann

Reputation: 89509

The "baseURL" part of "initWithBaseURL:" bit should make it clear that it's only going to work with the scheme + host + port number part.

Once you've created your client, you can add parameters onto it's URL request via techniques like:

NSMutableURLRequest *request = 
    [self.client requestWithMethod:@"POST" path:@"/api/games" parameters:parameters];

Upvotes: 2

Related Questions