我想使用restkit putobject發送放置請求,並從服務器接收響應爲200和字符串,但服務器給我400和說不接收主體。 請求是 請求:https://myserver.com/api/v1/f1/ /更新 體= 「someValue中」 響應是200 「someValue中」服務器沒有從webservice調用restkit接受body對象
此我有restkit implment 請求https://myserver.com/api/v1 路F1 //更新
這裏是代碼
RKObjectMapping *responseMapping = [RKObjectMapping mappingForClass:[ModelUpdate class]];
[responseMapping addPropertyMapping:[RKAttributeMapping attributeMappingFromKeyPath:nil toKeyPath:@"status"]];
RKResponseDescriptor *responseDescriptor =
[RKResponseDescriptor responseDescriptorWithMapping:responseMapping
method:RKRequestMethodPUT
pathPattern:path
keyPath:nil
statusCodes:[NSIndexSet indexSetWithIndex:200]];
*objectPath=path;
RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:[responseMapping inverseMapping] objectClass:[ModelUpdate class] rootKeyPath:nil method:RKRequestMethodAny];
[rkObjectManager addResponseDescriptor:responseDescriptor];
[rkObjectManager addRequestDescriptor:requestDescriptor];
rkObjectManager.requestSerializationMIMEType = RKMIMETypeJSON;
[rkObjectManager putObject:someObj path:path parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
id updateField = mappingResult.array;
[sDFWebInterface->m_DFWebInterfaceData receiveResponse:updateField forRequestNo:requestNo error:nil];
NSLog(@"Success");
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Error from server in Put Request");
[sDFWebInterface HandleServerAPIError:requestNo :error];
}];
/////Modelupdate class
@interface ModelUpdate : NSObject
@property(nonatomic,strong)NSString* status;// :
@end
那麼服務器接收什麼是身體,你期望它接收什麼?什麼是'someObj'? – Wain
someobj基本上是一個字符串對象someobj =「newvalue」 – jatin