ios - Code=-1011 "Request failed: unauthorized (401)" AFNetwoking -


i'm trying make request setting header called

x-user-authorization i'm getting following error:

code=-1011 "request failed: unauthorized (401)" afnetwoking

 -(void) listargruposdedistancia     {         nsmutablearray *listadistancias = [[nsmutablearray alloc]init];         afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager];         manager.requestserializer = [afhttprequestserializer serializer];         manager.requestserializer.allowscellularaccess = yes;         [manager.requestserializer setvalue:@"valuehere" forhttpheaderfield:@"x-user-authorization"];         afsecuritypolicy *policy = [afsecuritypolicy policywithpinningmode:afsslpinningmodenone];         policy.allowinvalidcertificates = yes;         manager.securitypolicy = policy;          nsstring *url = @"https://url:3000/api/v0.1/groups/";          [manager get:url           parameters:nil              success:^(afhttprequestoperation *operation, id responseobject) {                  nslog(@“success”);                  }                  [self concluirlistadistancias:listadistancias];               } failure:^(afhttprequestoperation *operation, nserror *error) {                  nslog(@"error: %@", error);              }];     } 

you're getting 401 server - meaning haven't constructed appropriate http request authentication according server requires. review documentation of (service provider or in case appears local packaged product), use tools , construct appropriate http request. when you're confident raw requests working expected, use requestb.in test afnetworking request.

for it's worth, x-user-authorization isn't pre-configured authorization header (the x- prefix implies it's custom header attribute). maybe you're looking more authorization: bearer <token>?


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -