Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response"

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];
like image 556
user2381124 Avatar asked Apr 23 '15 10:04

user2381124


People also ask

What NSURLErrorDomain 1017?

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.

Why is my Safari saying Cannot parse response?

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.

What does it mean when it says Cannot parse response?

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.


2 Answers

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"];
like image 136
priyanka gautam Avatar answered Nov 14 '22 22:11

priyanka gautam


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.

like image 32
Daniel Kuta Avatar answered Nov 14 '22 22:11

Daniel Kuta