Looking for an example of how to post json with AFHTTPClient
. I see that there is a postPath method which takes an NSDictionary
and the AFJSONEncode me
If you're posting to a JSON REST API, there should be a particular mapping from object property to JSON key, right? That is, the server is expecting certain information in certain named fields.
So what you want to do is construct an NSDictionary
or NSMutableDictionary
with the keys used in the API and their corresponding values. Then, simply pass that dictionary into the parameters
argument of any request method in AFHTTPClient
. If the parameterEncoding
property of the client is set to AFJSONParameterEncoding
, then the body of the requests will automatically be encoded as JSON.