Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-27-2010, 03:49 AM   #2 (permalink)
sambasivarao4u
Registered Member
 
Join Date: Jul 2010
Posts: 7
sambasivarao4u is on a distinguished road
Default JSON Request over Http Post

NSData *topImageData = UIImageJPEGRepresentation(pickedImage, 1.0);
NSString *myString=[NSString stringWithFormat:@"%@",topImageData];

NSArray *keysArray=[NSArray arrayWithObjects:@"transactionId",@"image",nil];
NSArray *objectsArray=[NSArray arrayWithObjects:@"1",myString,nil];

NSDictionary *theRequestDictionary=[[[NSDictionary alloc] initWithObjectsbjectsArray forKeys:keysArray] autorelease];

NSArray *keysArray1=[NSArray arrayWithObjects:@"transactions",nil];
NSArray *objectsArray1=[NSArray arrayWithObjects:theRequestDictionary,nil];

NSDictionary *myRequestDictionary=[[NSDictionary alloc] initWithObjectsbjectsArray1 forKeys:keysArray1];

NSURL *theURL = [NSURL URLWithString:@"http://10.10.39.92:8080/taxdeductableproductfinder/calculator/tax/image"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0f];
[theRequest setHTTPMethod:@"POST"];

[theRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString *theBodyString = [[CJSONSerializer serializer] serializeDictionary:myRequestDictionary];
NSString *appendedBodyString=[NSString stringWithFormat:@"analysisRequest={\"productFinde rRequest\":%@}",theBodyString];
NSLog(@"Request in JSON Format ->%@", appendedBodyString);
NSData *theBodyData = [appendedBodyString dataUsingEncoding:NSUTF8StringEncoding];
//NSLog(@"Request Body-->%@", theBodyData);
[theRequest setHTTPBody:theBodyData];

NSURLResponse *theResponse = NULL;
NSError *theError = NULL;
NSData *theResponseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&theResponse error:&theError];
NSLog(@"response data %@",theResponseData);
sambasivarao4u is offline   Reply With Quote
 

» Advertisements
» Online Users: 445
13 members and 432 guests
antonwilliams, chits12345, daniljan, darrenshain, ephefei, erdinc27, EvilElf, ipodphone, jaychoupham, JmayLive, linkmx, Mnadeep, observer247
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,588
Threads: 94,083
Posts: 402,775
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daniljan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:42 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.