1
我正在執行Restkit GET操作,但在Restkit中出現錯誤。我想同樣的操作與REST控制檯上的Chrome和它的工作原理:獲取操作時出現REstkit錯誤
GET操作的細節是: 網址:https://www.ez-point.com/ezpoints 操作:GET 認證頭:xxxxxxxxxxxxxxxxxxx
隨着Chrome的REST控制檯,它工作和我在JSON得到適當的迴應。
使用Restkit,它不起作用。這些都是我Restkit代碼:
//trying restkit
NSURL *endpoint = [NSURL URLWithString:@"https://www.ez-point.com/"];
RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:endpoint];
[objectManager.HTTPClient setAuthorizationHeaderWithToken:@"xxxxxxxxxxxxxxxxxxx"];
[objectManager getObjectsAtPath:@"ezpoints" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSLog(@"Success");
//NSLog(mappingResult);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Failure");
//NSLog(operation);
//NSLog(error);
}];
我得到這個錯誤:
2013-10-25 11:00:11.690 EZ-POINT[1089:c07] I restkit:RKLog.m:34 RestKit logging initialized...
2013-10-25 11:00:12.820 EZ-POINT[1089:c07] I restkit.network:RKObjectRequestOperation.m:180 GET 'https://www.ez-point.com/ezpoints'
2013-10-25 11:00:14.184 EZ-POINT[1089:4507] E restkit.network:RKObjectRequestOperation.m:576 Object request failed: Underlying HTTP request operation failed with error: Error Domain=org.restkit.RestKit.ErrorDomain Code=-1016 "Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/html" UserInfo=0x110a3560 {AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest https://www.ez-point.com/ezpoints>, NSErrorFailingURLKey=https://www.ez-point.com/ezpoints, NSLocalizedDescription=Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/html, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x110b42b0>}
2013-10-25 11:00:14.185 EZ-POINT[1089:4507] E restkit.network:RKObjectRequestOperation.m:243 GET 'https://www.ez-point.com/ezpoints' (401 Unauthorized/0 objects) [request=0.0000s mapping=0.0000s total=1.3657s]: Error Domain=org.restkit.RestKit.ErrorDomain Code=-1016 "Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/html" UserInfo=0x110a3560 {AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest https://www.ez-point.com/ezpoints>, NSErrorFailingURLKey=https://www.ez-point.com/ezpoints, NSLocalizedDescription=Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/html, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x110b42b0>}
2013-10-25 11:00:14.599 EZ-POINT[1089:c07] Failure
什麼建議嗎?
我在u're app中添加了代碼行,但同樣的錯誤。 – Noor
是的,因爲你沒有註冊序列化類(見編輯答案)。 – tilo
隨着你的代碼,我收到一個錯誤:未知的接收者'RKXMLReaderSerialization';你的意思是RKURLEncodedSerialization? – Noor