I am trying for an HTTP call on https. Here is my code snippet.
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
initWithURL:[NSURL
URLWithString:@"https://testservice.fiamm.com/token"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-type"];
NSString *postString = @"username=TestIphone&Password=T3st1ph$n&Grant_type=password";
[request setValue:[NSString stringWithFormat:@"%d", [postString length]] forHTTPHeaderField:@"Content-length"];
[request setHTTPBody:[postString
dataUsingEncoding:NSUTF8StringEncoding]];
// Fetch the JSON response
NSData *urlData;
NSURLResponse *response;
NSError *error;
// Make synchronous request
urlData = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
// Construct a String around the Data from the response
NSString *strFiamm = [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding];
When I try in hurl or postman I get response proper but when I try in my code I get this error.
NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
Any help or suggestions appreciated.!
The link that you mentioned here is not https certificate in it so use simple http not https
Edit #1
I tried these values
http://testservice.fiamm.com/token
username=TestIphone
Password=T3st1ph$n
Grant_type=password
and output is
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
that means your username password or key values are not correct