Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSData *finalData = [NSJSONSerialization dataWithJSONObject:mainDictionary options:NSJSONWritingPrettyPrinted error:nil];
- //Calculate data length to post
- NSString *postLength = [NSString stringWithFormat:@"%d", [finalData length]];
- NSString *str2 =[[NSString alloc] initWithData:finalData encoding:NSUTF8StringEncoding];
- NSLog(@"Final Json : %@",str2);
- NSString *urlString=[NSString stringWithFormat:@"%@%@",BASE_URL,EXT_URL];
- NSMutableURLRequest *theRequest=[NSMutableURLRequest
- requestWithURL:[NSURL URLWithString:
- urlString]
- cachePolicy:NSURLRequestUseProtocolCachePolicy
- timeoutInterval:60.0];
- [theRequest setHTTPMethod:@"POST"];
- [theRequest addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
- [theRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
- [theRequest setHTTPBody:finalData];
- [NSURLConnection sendAsynchronousRequest:theRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
- if (error) {
- //do something with error
- } else {
- NSString *responseText = [[NSString alloc] initWithData:data encoding: NSASCIIStringEncoding];
- NSLog(@"Response: %@", responseText);
- NSString *newLineStr = @"n";
- responseText = [responseText stringByReplacingOccurrencesOfString:@"<br />" withString:newLineStr];
- }
- }];
- "inventoryType" : 0,
- "customerAddress" : "City",
- "customerName" : "abc",
- "DOJ" : "2014-09-30",
- "boardingPoint" : {
- "id" : "4",
- "location" : "Nothing",
- "time" : "06:55PM"
- },
- "PaxDetails" : [
- {
- "nameOnId" : "abc",
- "mobile" : "2760",
- "lastName" : "D",
- "primary" : true,
- }
- ],
- "customerEmail" : "abc@gmail.com",
- "destinationCity" : "XYZ",
- "customerPhone" : "2760",
- "emergencyPhNumber" : "1234",
- "customerLastName" : "D",
- }
- Response: <html><head><title>JBoss Web/7.0.13.
- Final - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
- H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
- H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
- BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
- P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
- </head><body><h1>HTTP Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b>
- Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The requested resource () is not available.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.0.13.Final</h3></body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement