0

I am hitting the JIRA api authentication url from https://developer.atlassian.com/jiradev/api-reference/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-basic-authentication.

When I enter the right username and password, it returns the token in response but when I enter the wrong password and username then it is returning the same token. I cannot resolve this problem please can someone help me.

I am using this code.

NSURL * urlToHit = [NSURL URLWithString:loginUrl];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:urlToHit cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:300];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[data length]];

[request setHTTPMethod:[customizedHeaders valueForKey:HTTP_HEADER_METHOD_TYPE]?:@"POST"];
//  NSLog(@"%@",[request setHTTPMethod])
[request setValue: postLength forHTTPHeaderField:HTTP_HEADER_CONTENT_LENGTH];
[request setValue:[customizedHeaders valueForKey:HTTP_HEADER_ACCEPT]?:@"*/*" forHTTPHeaderField:HTTP_HEADER_ACCEPT];
[request setValue:[customizedHeaders valueForKey:HTTP_HEADER_CONTENT_TYPE]?:@"application/json" forHTTPHeaderField:HTTP_HEADER_CONTENT_TYPE];
[request setHTTPBody:data];
NSError *error = nil;
NSHTTPURLResponse *response = nil;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"~~~~~ Status code: %ld", (long)[response statusCode]);
Popeye
  • 11,839
  • 9
  • 58
  • 91
Tinku
  • 247
  • 1
  • 3
  • 13

1 Answers1

0

You can clear all the url cache by using

[[NSURLCache sharedURLCache] removeAllCachedResponses];

or clear a particular cache by using

[NSURLCache sharedURLCache] removeCachedResponseForRequest:yourRequest];

You can also use a different caching policy during creation of your request like NSURLRequestReloadIgnoringCacheData this should also work. Look at question

Community
  • 1
  • 1
iHulk
  • 4,869
  • 2
  • 30
  • 39