0

I have a NSMutableURLRequest that has been created like so:

AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:<my url>];
urlRequest = [httpClient requestWithMethod:<my method>
                                      path:<my uri>
                                parameters:<my parameters>];

At some point later in my program, I wish to append additional parameters to the urlRequest (while keeping everything else unchanged) before running the network operation. How would I go about doing this?

Stunner
  • 12,025
  • 12
  • 86
  • 145

1 Answers1

0

Looking to AFNetworking it returns a NSMutableRequest object. ​

- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
                                      path:(NSString *)path
                                parameters:(NSDictionary *)parameters

Now depending of the type of request you're doing (GET,POST,PUT,DELETE) you can access to the request parameter by:

GET: request.URL.parameterString

POST: request.HTTPBody

Fabian N.
  • 3,807
  • 2
  • 23
  • 46
rodchile
  • 181
  • 1
  • 9
  • Right, but there is no convenient method in the AFNetworking library that allows for appending of parameters? I know I can dig in and do it myself, but I'd rather not if there already is a well-tested method written to do it. – Stunner Sep 12 '13 at 01:16
  • I would suggest in that case create a mutableDictionary with a convenient method where it will create a new request with your parameters. – rodchile Sep 12 '13 at 01:31