0

I'm using AFNetworking 2.0 for a normal GET request and the parameter dictionary seems to be having no effect. I'm using the standard:

 [manager GET:URLString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {...

but my NSMutableDictionary (parameters) doesn't seem to have any effect on the URL sent in the GET request (GET requests don't have HTTP Bodies as far as I'm aware so they won't be there). So where are the parameters going? I know I could always amend the string, but the way in which I receive the parameters on an optional basis makes it far easier to just send in a dictionary. What's wrong, why isn't it working?

Thanks,
Mike

UPDATE: I'm setting the parameter like this: [parameters setValue:self.Object.ID forKey:@"Filter.Id"]; ID is a string. However, when I do [parameters valueForKey:@"Filter.Id"] I get a (null) in the NSLog. I'm going to mess around with it a little and see how it goes, but if you have any ideas why this is happening I'd appreciate it. Also, parameters is an NSMutableDictionary and is a property of the ViewController.

Mackey18
  • 2,322
  • 2
  • 25
  • 39
  • *Usually* but not necessary, the parameters will go into the query component of the URL. As usual, can you provide more info, e.g. print the request (and the url) before the request will be send, any errors, the request body (if any)? You should now have enough experience to accomplish this easily ;) – CouchDeveloper Oct 21 '13 at 18:34
  • If you are using AFNetworking 2.0, shouldn't your signature be - (NSURLSessionDataTask *)GET:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(NSURLSessionDataTask *task, id responseObject))success failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; – Pradeep Mahdevu Oct 21 '13 at 21:02
  • @CouchDeveloper Hello again. By the way, the encoding issue we had with AFN 2.0 suddenly disappeared, I removed the custom encoding and all of sudden it worked! But yea, I printed the URL in the request and it just leaves off the parameters, doesn't add anything. – Mackey18 Oct 21 '13 at 21:51
  • @Mackey18 The custom encoding and the built-in encoding is almost identical. The resulting parameter string is identical if the param values don't have spaces, and a few other ASCII characters like "[", "]", "~", (a few more). However, the built-in encoding wouldn't encode correctly if your param values have spaces. – CouchDeveloper Oct 22 '13 at 07:05
  • @CouchDeveloper ok, I don't think there are any spaces but I'll double check when I get back. Then I'll report back. – Mackey18 Oct 22 '13 at 11:05
  • @CouchDeveloper Hey, seems that it's issues with my parameter that I'm passing. Have a look at my updated question. – Mackey18 Oct 22 '13 at 17:16

1 Answers1

0

Was an issue with my NSMutableDictionary property. Changed it to a global variable and everything worked fine!

Thanks,
Mike

Mackey18
  • 2,322
  • 2
  • 25
  • 39