我在我的项目中使用“RestKit 0.20.3”,
由于一些重要原因,我将把所有API调用转换为Ret套件,
请任何人告诉我如何使用休息套件进行如下调用
我发送了ASIHHTP
代码
请任何人将其迁移到Rest套件,我无法找到方法
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]];
答案 0 :(得分:0)
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
}
}];