相关疑难解决方法(0)

请求失败:不可接受的内容类型:使用AFNetworking 2.0的text/html

我正在尝试AFNetworking的新版本2.0,我收到了上面的错误.知道为什么会这样吗?这是我的代码:

    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];
Run Code Online (Sandbox Code Playgroud)

我正在使用Xcode 5.0.

此外,这是错误消息:

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" = …
Run Code Online (Sandbox Code Playgroud)

ios afnetworking afnetworking-2

201
推荐指数
7
解决办法
17万
查看次数

标签 统计

afnetworking ×1

afnetworking-2 ×1

ios ×1