Here I am getting error while I post json.
Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo=0x7f89dac01a40 {NSUnderlyingError=0x7f89e0277a20 "cannot parse response", NSErrorFailingURLStringKey=http://test-onboard.qlc.in/FieldSense/authenticate, NSErrorFailingURLKey=http://test-onboard.qlc.in/FieldSense/authenticate, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-1, NSLocalizedDescription=cannot parse response}
Here is my code:
NSDictionary *dictionaryData=[[NSDictionary alloc]initWithObjectsAndKeys:self.txtUsername.text, @"userEmailAddress", self.txtPassword.text, @"password",nil];
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dictionaryData options:kNilOptions error:&error];
[request setURL:url];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:jsonData];
Overview. Certain web apps or websites deployed behind OAG that use WordPress may give this error (NSURLErrorDomain: -1017)” in Safari for web, iOS or iPadOS. The application still works when using other browsers like Chrome or Firefox.
The message of cannot parse response by the Safari browser could be a result of a temporary communication glitch between the Mac and router. In this context, performing a cold restart of the Mac and router may solve the problem. Power off the Mac and router. Afterward, plug back the power cables of the Mac and router.
You are reaching the HTTP size limit. Some users have reported the “Unable to parse response body” error when bulk indexing a huge volume of data. This happens because Elasticsearch by default has a maximum size of HTTP request body of 100Mb (you can change the http.
I am also getting this error but i overcome this by adding a line
request.HTTPMethod = "POST"
for Objective-C programming use this:
[request setHTTPMethod:@"POST"];
I had the same problem with Alamofire and the error caused this:
let encoding = Alamofire.ParameterEncoding.JSON
let (encodedRequest, _) = encoding.encode(URLRequest, parameters: params)
my variable params was dict [:]. I changed to parameters: nil and it's work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With