Note that there are some explanatory texts on larger screens.

plurals
  1. POAFNetworking 2.0 - "unacceptable content-type: text/plain"
    primarykey
    data
    text
    <p>I'm using AFNetworking 2.0 to read JSON from a service I'm building (on <code>localhost</code> for now) in Node. Pretty normal stuff. </p> <p>Node is sending JSON like so:</p> <pre><code>res.setHeader('Content-Type','application/json'); res.end( JSON.stringify(...)); </code></pre> <p>My iOS first-pass code is attempting to read that data like so:</p> <pre><code>typedef void(^NextBlock)(); AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; [manager GET:self.newestTimestampURL.absoluteString parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { //NSDictionary *response = NSLog(@"got %@", responseObject ); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"fail %@", error ); }]; </code></pre> <p>This is the error I'm getting:</p> <pre><code>Error Domain=AFNetworkingErrorDomain Code=-1016 "Request failed: unacceptable content-type: text/plain" UserInfo=0xb783e30 {NSErrorFailingURLKey=http://localhost:3000/api/v1/log/newest, AFNetworkingOperationFailingURLResponseErrorKey=&lt;NSHTTPURLResponse: 0xb656a70&gt; { URL: http://localhost:3000/api/v1/log/newest } { status code: 200, headers { Connection = "keep-alive"; ContentType = "application/json"; Date = "Fri, 27 Dec 2013 20:58:50 GMT"; "Transfer-Encoding" = Identity; } }, NSLocalizedDescription=Request failed: unacceptable content-type: text/plain} </code></pre> <p>I can curl (-i) the url <code>http://localhost:3000/api/v1/log/newest</code> and get the data I'm expecting, and it's application/json as expected. If I load that data in my web browser, I get JSON as expected per dev tools inspector.</p> <p>But using AFNetworking, I get this mysterious "unacceptable content-type: text/plain" error. Any idea?</p> <p>NOTE: I've never used AFNetworking before, so I'm probably using it incorrectly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload