ios - Issue while setting HTTP header through AFNetwokring -
problem:
- (void) getreportsummarywithcompletionblock:(void (^)(bool success))success { nsstring *storedtoken = [[user shareduser] accesstoken]; nslog(@"stored class: %@",[storedtoken class]); //logs -- __nscfstring nsstring *constanttoken = @"e5c47aa3-c168-480b-a10c-1c4379096fbf"; nslog(@"constant class: %@",[constanttoken class]); //logs -- __nscfconstantstring [self.manager.requestserializer setvalue:constanttoken forhttpheaderfield:@"authorization"]; //[self.manager.requestserializer setvalue:storedtoken forhttpheaderfield:@"authorization"]; [self.manager get:someurlstring parameters:nil success:^(afhttprequestoperation *operation, id responseobject) { nslog(@"%@",responseobject); success(yes); } failure:^(afhttprequestoperation *operation, nserror *error) { success(no); }];
when log value of storedtoken prints "e5c47aa3-c168-480b-a10c-1c4379096fbf"
and constanttoken prints e5c47aa3-c168-480b-a10c-1c4379096fbf withtout ".
when use constanttoken server responds correctly when use storedtoken server reponse not correct.
question:
now there workaround issue? anyway cast nscfstring nscfconstantstring ?
thanks in advance :).
you storing storedtoken
@"\"xxx-yyy-zzz-bla-bla\""
please save correctly or ask server send string without double quotes
for time being can trim "
, can replace "
empty sting won't recommend that
nsstring *goodtoken = [storedtoken stringbytrimmingcharactersinset:[nscharacterset charactersetwithcharactersinstring:@"\""]]; nslog(@"%@", goodtoken);
p.s.
this should seen temporary fix, should save token don't have double quotes. please onto code , find why you're getting double quotes, might server sending string double quotes.
Comments
Post a Comment