1 EKİM 2013, Salı
İstek başarısız oldu: kabul edilemez-içerik türü: metin/html kullanarak 2.0 AFNetworking
Yeni sürüm 2.0 AFNetworking olan deniyorum ve yukarıdaki hatayı alıyorum. Bu neden oluyor bir fikriniz var mı? İşte benim kod:
NSURL *URL = [NSURL URLWithString:kJSONlink];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
op.responseSerializer = [AFJSONResponseSerializer serializer];
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[[NSOperationQueue mainQueue] addOperation:op];
Herhangi bir fikir takdir edilecektir. Eğer yardımcı olur da böyle büyük mükafat 5.0 kullanıyorum. Teşekkürler!
Ayrıca, burada hata iletisi:
Error: Error Domain=AFNetworkingErrorDomain Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0xda2e670 {NSErrorFailingURLKey=kJSONlink, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0xda35180> { URL: kJSONlink } { status code: 200, headers {
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 2898;
"Content-Type" = "text/html";
Date = "Tue, 01 Oct 2013 10:59:45 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = Apache;
Vary = "Accept-Encoding";
} }, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
Ben sadece JSON kJSONlink kullanarak sakladı. Bu bir JSON dönmelidir.
CEVAP
1 EKİM 2013, Salı
Bu sunucu zaten desteklenen türler yerine "text/html"
gönderme olduğu anlamına gelir.
Benim çözüm acceptableContentTypes
"text/html"
AFURLResponseSerialization
sınıftaki eklemek oldu. Sadece "acceptableContentTypes" ve el ile ayarlamak için @"text/html"
ekleyin. için arama
Tabii ki, ideal tip sunucudan gönderilen değiştirmek için, ama bunun için server ekibi ile konuşmak zorunda kalacak.
Bunu Paylaş:
Doğrulama Sunucu Veritabanı Varlık Çer...
HTML Giriş="dosya" Öznitelik...
CSS içerik özelliği: HTML ekleme için ...
HTML dosyası Python kullanarak açılan ...
Değer dökme türü 'Int32' hay...