Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:45:46+00:00 2026-05-29T07:45:46+00:00

I am trying to retrieve some JSON data with AFNetworking. My server component (PHP/ZendFramework)

  • 0

I am trying to retrieve some JSON data with AFNetworking.

My server component (PHP/ZendFramework) delivers the following response:

>curl -i http://test.local:8080/public/appapi/testaction/format/json
HTTP/1.1 200 OK
Date: Mon, 06 Feb 2012 10:37:20 GMT
Server: Apache
X-Powered-By: PHP/5.3.8
Content-Length: 35
Content-Type: application/json
{"entries":"test","abcxxx":"test2"}

I try to use the following code to retrieve this json data:

NSString *baseurl = @"http://test.local:8080";

NSString *path = @"/public/appapi/testaction/format/json";

AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:baseurl]];
[client registerHTTPOperationClass:[AFJSONRequestOperation class]];
[client setAuthorizationHeaderWithUsername:@"myusername" password:@"mypassword"];

[client getPath:path parameters:nil success:^(__unused AFHTTPRequestOperation *operation, id JSON) {

    //NSLog(@"sjson: %@", [JSON valueForKeyPath:@"entries"]);
    NSLog(@"sjson: %@", JSON);        
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error Code: %i - %@",[error code], [error localizedDescription]);
}];

When running in the simulator the console shows the following output:

2012-02-06 11:22:39.800 App[3642:15803] sjson: <6a736f6e 466c6963 6b724170 69287b22 6d657468 6f64223a 7b225f63 6f6e7465 6e74223a 22666c69 636b722e 74657374 2e656368 6f227d2c 2022666f 726d6174 223a7b22 5f636f6e 74656e74 223a226a 736f6e22 7d2c2022 6170695f 6b657922 3a7b225f 636f6e74 656e7422 3a223336 32306666 32343265 37323336 34633135 32373031 31353438 62393335 3066227d 2c202273 74617422 3a226f6b 227d29>

Any hint on what I am doing wrong would be greatly appreciated 🙂 I tried accessing the Twitter API and that works perfectly fine…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:45:46+00:00Added an answer on May 29, 2026 at 7:45 am

    This is confusing, and something I’ve been trying to figure out how to properly document / design better, but you need to set your Accept header for the request to application/json.

    Registering AFJSONRequestOperation says “any request that comes through, I’ll look at and handle if it is a JSON request”. The way you hint that a request is JSON is to either set the appropriate Accept header, or add .json as the extension. Right now, the request is going through the list of operation classes, but it only catches on AFHTTPRequestOperation, which has a response object type of NSData (what you’re seeing in the log).

    Sorry about the confusion!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to retrieve some data from a JSON response, but this doesn't seem
I was trying to retrieve some JSON data from Google's AppEngine, and also a
I am basically trying to retrieve some data from a MySql server, and display
Hi i'm trying to retrieve response after passing some variables from javascript to php
So, I'm trying to use Doctrine to retrieve some data. I have some basic
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I'm trying to retrieve some data from the FaceBook graph API. The API URL
I'm trying to retrieve JSON data from a remote site with Rails/Prototype. I've found
I am trying to retrieve JSON formatted data from a remote domain (Zencoder video
I am trying to use LINQ to retrieve some data from a dictionary. var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.