サーバーにリクエストを送信したいのですが、次のリクエストヘッダーを持つ PUT リクエストです。
Content-Type: application/json; charset=UTF-8
そして以下NSDictionary
:
{"title": "Sumit"}
reskit を使用して put リクエストを作成しています。put リクエストは作成されますが、ヘッダーに関連するエラーが発生します。リモートサーバーにリクエストを送信するときにヘッダーと辞書を設定する方法を知りたいです。また、次のRKObjectManager
中でこのタスクに最適な方法はどれですか:-
方法 1:-
- NSMutableURLRequest *request = [manager requestWithObject:newImage
method:RKRequestMethodPUT
path:[kImageUrl stringByAppendingString:imageUrl]
parameters:jsonParameters];
方法 2:-
- (NSMutableURLRequest *)multipartFormRequestWithObject:(id)object
method:(RKRequestMethod)method
path:(NSString *)path
parameters:(NSDictionary *)parameters
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block;
私が得ているエラー:-
(400 Bad Request) [0.4221 s]: Error Domain=AFNetworkingErrorDomain Code=-1016
"Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/plain" UserInfo=0xa0951c0 {NSLocalizedRecoverySuggestion=Bad Request,
AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest
http://staging.zoomdeck.com/api/image/c5ot31sxnh8v/>,
NSErrorFailingURLKey=http://staging.zoomdeck.com/api/image/c5ot31sxnh8v/,
NSLocalizedDescription=Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/plain, AFNetworkingOperationFailingURLResponseErrorKey=<
NSHTTPURLResponse: 0xa194530>}
2013-01-16 17:19:43.860 Zoomdeck[2905:4a07] E
restkit.network:RKObjectRequestOperation.m:285 Object request failed:
Underlying HTTP request operation failed with error: Error
Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/plain" UserInfo=0xa0951c0 {NSLocalizedRecoverySuggestion=Bad Request,
AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest
http://staging.zoomdeck.com/api/image/c5ot31sxnh8v/>,
NSErrorFailingURLKey=http://staging.zoomdeck.com/api/image/c5ot31sxnh8v/,
NSLocalizedDescription=Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/plain, AFNetworkingOperationFailingURLResponseErrorKey=
<NSHTTPURLResponse: 0xa194530>}
2013-01-16 17:19:43.861 Zoomdeck[2905:c07] Expected content type {(
"application/x-www-form-urlencoded",
"application/json"
)}, got text/plain