yokks
yokks

Reputation: 5773

problem in setting parameters for NSMutableURLRequest ( POST request)

am setting the parameters(key-value pairs - user name, password, email id) for NSMutableURLRequest(POST) using the class method

 + (void)setProperty:(id)value forKey:(NSString *)key inRequest:(NSMutableURLRequest *)request

and requesting the server using sendSynchronous.

But at the server end, the parameters are null.

plz suggest me some other new solution???

Upvotes: 0

Views: 2660

Answers (1)

Jeremy W. Sherman
Jeremy W. Sherman

Reputation: 36143

Use ASIFormDataRequest. Its -setPostValue:forKey: method makes POSTing data as application/x-www-urlformencoded or multipart/form-data dead simple.

If you want to use NSURLRequest instead, check out the OAuthConsumer project for an example of using application/x-www-form-urlencoded. Start by reading -setParameters: in NSMutableURLRequest+Parameters.m and go from there. For sending data asmultipart/form-datausingNSURLRequest`, see Facebook's FBRequest.

+[NSURLProtocol setProperty:forKey:inRequest:] is intended to be used to extend the URL loading system to support additional protocols:

Protocol implementors who need to extend the capabilities of NSURLRequest and NSMutableURLRequest [by providing categories on these classes] can store and retrieve protocol-specific request data by using NSURLProtocol’s class methods propertyForKey:inRequest: and setProperty:forKey:inRequest:. (here)

Upvotes: 2

Related Questions