Domanda

Sto usando "Restkit 0.20.3` nel mio progetto,

Per alcuni motivi cruciali, ho intenzione di convertire tutte le mie chiamate API al kit Ret,

Per favore, qualcuno posso dirmi come posso fare la stessa chiamata come sotto con il kit di riposo, sto inviando il mio ASIHHTP Codice Si prega di migrarlo per riposare il kit, non sono in grado di trovare la strada

NSDictionary *dictionary=....;

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@auth/login",KBASEURL]];


ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];


[request setRequestMethod:@"POST"];


[request setValidatesSecureCertificate:NO];


[request addRequestHeader:@"Content-Type" value:@"application/json; charset=utf-8"];


 NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataDictionary options:kNilOptions error:nil];

[request setPostBody:(NSMutableData *)jsonData];

[request setContentLength:[jsonData length]];
È stato utile?

Soluzione

RKObjectManager *manager =  [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"https://172.22.221.117/api/v1.0/"]];

 NSDictionary *dictionary=[NSDictionary dictionaryWithObjectsAndKeys:@"abc.com",@"email",@"password",@"password", nil];

[manager postObject:nil
               path:@"auth/login"
         parameters:dictionary
            success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {


            }
            failure:^(RKObjectRequestOperation *operation, NSError *error) {
                NSLog(@"Error: %@", error);
                if(operation.HTTPRequestOperation.response.statusCode==200){
                    //do your processing
                }
            }];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top