How can we post XML strings along with text strings in iOS -
nsstring *starcardstr=@"https://starcardsindia.com/test/api/userauthentication"; //nsstring *poststr=[nsstring stringwithformat:@"https://starcardsindia.com/api/otpverification"]; // nsurl *url=[nsurl urlwithstring:poststr]; nsurl *url=[nsurl urlwithstring:starcardstr]; nsmutableurlrequest *request=[[nsmutableurlrequest alloc]init]; [request seturl:[nsurl urlwithstring:starcardstr]]; [request sethttpmethod:@"post"]; nsstring *contenttype = [nsstring stringwithformat:@"text/xml"]; [request addvalue:contenttype forhttpheaderfield: @"content-type"]; nsmutabledata *pbody=[nsmutabledata data]; [pbody appenddata:[[nsstring stringwithformat:@"<xml>"] datausingencoding:nsutf8stringencoding]]; // create post [pbody appenddata: [[nsstring stringwithformat: @"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"] datausingencoding: nsutf8stringencoding]]; //[pbody appenddata:[[nsstring stringwithformat:@"<starcard> <mobie_no>9959571336</mobie_no><password>1234</password><date>2015-03-31</date><imei_no>1234</imei_no></starcard>"]datausingencoding:nsutf8stringencoding]]; //[request sethttpbody:pbody]; [pbody appenddata:[[nsstring stringwithformat:@"<starcard><mobileno>9959571336</mobileno><date>2015</date><imei_no>123456</imei_no></starcard>"]datausingencoding:nsutf8stringencoding]]; [request sethttpbody:pbody];`
string xmlstring = "" + "" + mobile + "" + "" + password + "" + "" + imei_no + "" + "" + formatteddate + "" + ""; – user3656396`
Comments
Post a Comment