[Answer]-Tell AFHTTPClient to add trailing slash automatically

1👍

You need to either

  1. Always provide the trailing / in your getPath: argument (like getPath:@"entry/"), or
  2. Subclass AFHTTPClient with a method that adds it.

Here’s an example of #2:

- (void)getPath:(NSString *)path 
     parameters:(NSDictionary *)parameters 
        success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
        failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
    if ([path length] > 0 && ![path hasSuffix:@"/"])
        path = [path stringByAppendingString:@"/"];

    [super getPath:path parameters:parameters success:success failure:failure];
}

Leave a comment