how to get response on http post method when post html data in ios?

Sanandiya Vipul

my code here... not receive all html data....so plz reply me on it:[email protected]

NSString *get_value_key=[NSString stringWithFormat:@"personen=%@&eigenaar=%@&soortwoning=%@&beveiliging=%@&soortdak=%@",[filter_ary4 objectAtIndex:[pickerView4 selectedRowInComponent:0]],[filter_ary7 objectAtIndex:[pickerView7 selectedRowInComponent:0]],[filter_ary8 objectAtIndex:[pickerView8 selectedRowInComponent:0]],[filter_ary9 objectAtIndex:[pickerView9 selectedRowInComponent:0]],[filter_ary10 objectAtIndex:[pickerView10 selectedRowInComponent:0]]];



NSData *postData = [get_value_key dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://media.komparu.com/inboedelverzekering/10045724/5193"]];


[request setHTTPMethod: @"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"text/html; charset=UTF-8" forHTTPHeaderField: @"Content-Type"];
[request setHTTPBody:postData];

// NSError *requestError;
NSURLResponse *urlResponse =nil;

response1 = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:nil];

NSString *requestReply = [[NSString alloc] initWithBytes:[response1 bytes] length:[response1 length] encoding:NSASCIIStringEncoding];
NSLog(@"requestReply: %@", requestReply);
zaph

If you want the response it is in the variable: urlResponse.

If you want the html status code cast the response to NSHTTPURLResponse and access the statusCode property.

Or just create NSHTTPURLResponse instead of NSURLResponse and access directly.

NSError *error;
NSHTTPURLResponse *urlResponse;
response1 = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
NSInteger statusCode = urlResponse.statusCode;
NSLog(@"statusCode: %i", statusCode);
if (response1) {
    // process data
}
else {
    // Log the response and error description
    NSLog(@"urlResponse: %@", urlResponse);
    NSLog(@"error: %@", error);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

get response when i call the post method

iOS post data to get JSON response

How to get JSON data with HTTP Post method in swift 3?

how to get http response from typescript post

iOS Get JSON response from AFNetworking HTTP POST method with JSON parameters

jQuery Ajax PHP POST method with response array[] instad sent data. How to get send values in response?

Http post get response Android

Node JS Azure function get the response data after post method

How to get type of HTTP POST data?

How to Get the HTTP Post data in C#?

How do I Mock a method that makes multiple POST and GET request all requiring different response data?

Http post method seen as http get method

How to get http POST's response's headers in Angular 8

How to get not encoded characters in response of http post in Python

How to make HTTP Post request and get the response as JSON Android

Xamarin Forms - How to get the json string in POST method response?

Ionic: Unable to get different data from $http post method

How to get query params when I use <form> with POST method to trigger Firebase http functions?

Not able to post JSON Data to MVC Action Method using $.AJAX but I get a Post 200 OK Response

When performing a POST HTTP method the "Response.status(Status.CREATED)" is recognised as undefined for the type "Response" by eclipse

How to get an HTML response after sending a POST request in Scrapy

How to fake guzzele post request to get response data in laravel

Get HTTP POST Response in Rails Controler

Difference between GET and POST in an HTTP response (not request)

Get http.post in javascript then send a response

http.post - getting response data

Access $http.post response data

Unable to get the response in POST method in Python

Fetch method POST - response data is Promise pending