Open kbabulrao opened 5 years ago
HI @kbabulrao Looks like the url you are passing in is invalid or you don't have permission? The server is returning 401, which sounds like you need to pass authorisation credentials.
getImageForURL:url requestHeaders:headers
might be the one you are looking for to pass your authorisation token along to the server?
To load the image, using the following code. But i am getting 401 error.
SGCachePromise promise = [SGImageCache getImageForURL:thumbnailURLString]; promise.then(^(UIImage image) { self.thumbnailImageView.image = image; }); promise.onRetry = ^{ // Called when SGImageCache automatically retries // fetching the image due to a reachability change. //[self showLoadingSpinner]; }; promise.onFail = ^(NSError *error, BOOL fatal) { // If the failure was fatal, SGImageCache will not // automatically retry (eg. from a 404) //[self displayError:error]; NSLog(@"---error---%@", error); };
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo={NSLocalizedDescription=Request failed: unauthorized (401), NSErrorFailingURLKey=https://thisisnotcorrecturl.net/api/CTImage?ActionFlagId=20&id=10224, com.alamofire.serialization.response.error.data=<596f7520 646f206e 6f742068 61766520 74686520 6e656365 73736172 79207065 726d6973 73696f6e 20746f20 70657266 6f726d20 74686973 20616374 696f6e2e>, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x600000c20640> { URL: https://thisisnotcorrecturl.net/api/CTImage?ActionFlagId=20&id=10224 } { Status Code: 401, Headers { "Cache-Control" = ( "no-cache" ); "Content-Length" = ( 64 ); "Content-Type" = ( "text/plain; charset=utf-8" ); Date = ( "Sun, 03 Mar 2019 11:06:37 GMT" ); Expires = ( "-1" ); Pragma = ( "no-cache" ); Server = ( "Microsoft-IIS/10.0" ); "X-AspNet-Version" = ( "4.0.30319" ); "X-Powered-By" = ( "ASP.NET" ); } }}