My Blog List

Thursday 27 September 2012

Posting JSON data to WCF REST from iPhone app

Hi,fellas
this is quick post related to posting JSON data to WCF REST web service from iphone or ipad application.


look at the code below








1. Construct your JSON NSString as



     NSString *jsonRequest=@"{\"user\":{\"EmailId\":\"bpsingh216@gmail.com\",\"Password\":\"pass\",\"UserRoleId\":2,\"UserDetails\":{\"FirstName\":\"bp\",\"FamilyName\":\"Singh\",\"CountryId\":1,\"StateId\":1,\"CityId\":2,\"ZipCode\":221712}}}";


2.Construct your url using NSURL
3.Create NSMutableURLRequest with url
4.Create NSData using jsonRequest.
4.set request method i.e. POST or GET
5.set value for Accept and Content-Type
6. set NSData as HTTPBody
7. Execute your request

No comments:

Post a Comment