Objective c 如何使用restkit完成post

Objective c 如何使用restkit完成post,objective-c,ios,web-services,post,restkit,Objective C,Ios,Web Services,Post,Restkit,我正在使用restkit构建一个应用程序来与我的Web服务对话。首先,我对这个很陌生。我需要做的是将用户名和密码发布到我的Web服务中,以便url如下所示 http://urllinkcompany.com/en/webservice/company-user/login/apikey/key12345678?email=test@test.be&pwd=testtest 当我发布这篇文章时,我得到了一个json回复。此json包含一个状态代码状态=200-->正常 状态=404-->

我正在使用restkit构建一个应用程序来与我的Web服务对话。首先,我对这个很陌生。我需要做的是将用户名和密码发布到我的Web服务中,以便url如下所示

http://urllinkcompany.com/en/webservice/company-user/login/apikey/key12345678?email=test@test.be&pwd=testtest
当我发布这篇文章时,我得到了一个json回复。此json包含一个状态代码<代码>状态=200-->正常 状态=404-->不正常

现在我试着发布一些东西并记录这个状态码

- (IBAction)login:(id)sender {

    RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Person class]];
    [mapping addAttributeMappingsFromDictionary:@{
     @"data.user.cu_email":     @"cu_email",

     }];


    RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:mapping pathPattern:nil keyPath:nil statusCodes:nil];

    NSString *baseUrl = @"http://urllinkcompany.com/en/webservice/company-user/login/apikey/key12345678?";
    NSString *strUrl = [NSString stringWithFormat:@"%@email=%@&pwd=%@",baseUrl,_txtLogin.text,_txtPass.text];
    NSURL *url = [NSURL URLWithString:strUrl];
    NSLog(@"url is: %@",strUrl);
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[responseDescriptor]];
    [operation setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *result) {
         NSLog(@"data result is %@", [result valueForKeyPath:@"data.status"]);
    } failure:nil];

}
但我得到了这个错误

 E restkit.network:RKObjectRequestOperation.m:285 Object request failed: Underlying HTTP request operation failed with error: Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x1ed57c50 {NSUnderlyingError=0x20161e70 "bad URL", NSLocalizedDescription=bad URL}
2013-01-07 11:48:51.407 Offitel2[22086:907] I restkit.network:RKHTTPRequestOperation.m:152 GET '(null)'
2013-01-07 11:48:51.408 Offitel2[22086:907] E restkit.network:RKHTTPRequestOperation.m:173 GET '(null)' (0) [0.0010 s]: Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x1ed57c50 {NSUnderlyingError=0x20161e70 "bad URL", NSLocalizedDescription=bad URL}
有人能帮我吗

亲切问候

编辑: 这是一个没有RKClient的版本

RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:[NSURL URLWithString:@"http://urllinkcompany.com/"]];

RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Person class]];
[mapping addAttributeMappingsFromDictionary:@{
 @"data.user.cu_email":     @"cu_email",
 }];

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:_txtLogin.text, @"email", _txtPass.text, @"pwd", nil];

[objectManager loadObjectsAtResourcePath:@"en/webservice/company-user/login/apikey/key12345678" delegate:self block:^(RKObjectLoader* loader) {
    loader.objectMapping = mapping;
    loader.method = RKRequestMethodPOST;
    loader.params = params;
}];
并实现这两个RKObjectLoaderDelegate方法:

- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects

- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error

新版本中不存在RKCLient,而且我在委托方法上出错。我使用RKObjectManager编辑了我的答案。这有帮助吗?不完全是,但它帮助我找到了正确的答案!谢谢你!