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 8819629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:24:34+00:00 2026-06-14T05:24:34+00:00

i am trying the json parsing but when parse then is gives error httppost

  • 0

i am trying the json parsing but when parse then is gives error
httppost method is not supported by this url
i put down my code here

http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=restaurants&rsz=8&sll=-27.5595451,-48.6206452&radius=1000&output=json

SearchListActivity.java

 public class SearchlistActivity extends Activity {

    private static String url="http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=restaurants&rsz=8&sll=-27.5595451,-48.6206452&radius=1000&output=json/";   private static final String TAG_RESULTS = "results";    private static final String TAG_RESPONSEDATA="responseData";    

        @Override
    public void onCreate(Bundle savedInstanceState)

    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Log.e("json ----","urlll---->"+url);       
        //JSONArray results = null;       
         JSONArray responseData=null;
     // Hashmap for ListView
        ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();

        // Creating JSON Parser instance
        JsonParserSearch jParser = new JsonParserSearch();

        // getting JSON string from URL
        JSONObject json = jParser.getJSONFromUrl(url);

        try {
            // Getting Array of Contacts

             responseData = json.getJSONArray(TAG_RESPONSEDATA);
             Log.e("jsonnn data","sfsssss00000-------->"+responseData);

            }
        catch (JSONException e) {
            e.printStackTrace();
        }

    } }

> 

Jsonparsersearch.java

public class JsonParserSearch { static InputStream is = null;
static JSONObject jObj = null;
static String json = “”;

// constructor
public JsonParserSearch() {

}

public JSONObject getJSONFromUrl(String url) {

    // Making HTTP request
    try {
        // defaultHttpClient
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();          

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        json = sb.toString();

       Log.e("json object url","display"+json);


    } catch (Exception e) {
        Log.e("Buffer Error", "Error converting result " + e.toString());
    }

    // try parse the string to a JSON object
    try {
        jObj = new JSONObject(json);
    } catch (JSONException e) {
        Log.e("JSON Parser finaal", "Error parsing data " + e.toString());
    }

    // return JSON String
    return jObj;

}      }
 >     > > lOGCAT ERROR
    >     > > 
    >     > > 11-09 12:23:17.700: E/json ----(481): urlll---->http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=restaurants&rsz=8&sll=-27.5595451,-48.6206452&radius=1000&output=json 11-09 12:23:18.260: E/json object url(481): display<HTML> 11-09
    >     > 12:23:18.260: E/json object url(481): <HEAD> 11-09 12:23:18.260:
    >     > E/json object url(481): <TITLE>HTTP method POST is not supported by
    >     > this URL</TITLE> 11-09 12:23:18.260: E/json object url(481): </HEAD>
    >     > 11-09 12:23:18.260: E/json object url(481): <BODY BGCOLOR="#FFFFFF"
    >     > TEXT="#000000"> 11-09 12:23:18.260: E/json object url(481): <H1>HTTP
    >     > method POST is not supported by this URL</H1> 11-09 12:23:18.260:
    >     > E/json object url(481): <H2>Error 405</H2> 11-09 12:23:18.260: E/json
    >     > object url(481): </BODY> 11-09 12:23:18.260: E/json object url(481):
    >     > </HTML> 11-09 12:23:18.260: E/JSON Parser finaal(481): Error parsing
    >     > data org.json.JSONException: Value <HTML> of type java.lang.String
    >     > cannot be converted to JSONObject 11-09 12:23:18.270:
    >     > D/AndroidRuntime(481): Shutting down VM 11-09 12:23:18.270:
    >     > W/dalvikvm(481): threadid=1: thread exiting with uncaught exception
    >     > (group=0x4001d800) 11-09 12:23:18.290: E/AndroidRuntime(481): FATAL
    >     > EXCEPTION: main 11-09 12:23:18.290: E/AndroidRuntime(481):
    >     > java.lang.RuntimeException: Unable to start activity
    >     > ComponentInfo{com.example.ssss/com.example.ssss.SearchlistActivity}:
    >     > java.lang.NullPointerException 11-09 12:23:18.290:
    >     > E/AndroidRuntime(481):  at
    >     > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    >     > 11-09 12:23:18.290: E/AndroidRuntime(481):  at
    >     > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    >     > 11-09 12:23:18.290: E/AndroidRuntime(481):  at
    >     > android.app.ActivityThread.access$2300(ActivityThread.java:125)
  • 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-06-14T05:24:35+00:00Added an answer on June 14, 2026 at 5:24 am

    You should use Get request instead of POST request.

    public class MainActivity extends Activity {
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        //make async request 
        new myAsynctask().execute();
    }
    
    //********************************************
    //get json string
    public String getJSONString() {
        StringBuilder builder = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
    
        String urlString="http://www.ajax.googleapis.com/ajax/services/search/local?v=1.0&q=restaurants&rsz=8&sll=-27.5595451,-48.6206452&radius=1000&output=json";
    
        HttpGet httpGet = new HttpGet(urlString);
        try {
            HttpResponse response = client.execute(httpGet);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                String line;
                while ((line = reader.readLine()) != null) {
                    builder.append(line);
                }
            } else {
                Log.e(getClass().getSimpleName(), "Failed to download json response");
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return builder.toString();
    }
    //********************************************
    private class myAsynctask extends AsyncTask<Void, Void, String>{
    
        @Override
        protected String doInBackground(Void... params) {
    
            String jsonString=getJSONString();
            return jsonString;
        }
        @Override
        protected void onPostExecute(String jsonString) {
            super.onPostExecute(jsonString);
            Log.e(getClass().getSimpleName(), jsonString);
        }
    }
    

    }

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

Sidebar

Related Questions

I'm trying to parse this very long and complicated JSON that foursquare gives me.
I'm having a problem parsing a JSON file in AS3. Im trying to parse
I have been trying to parse Json into A ListView but when i do
I am trying to parse json object to populate it into list view,but i
I am trying to parse this string .... but due to message_of_the_day key ,
I am trying to parse this test.json (It does validates, so that doesn't appear
I am currently trying to pass a generated JSON string to dojo for parsing
Trying to post JSON data to Spring controller.. Not working at all JSP Code:
I'm not pretty sure if this question is for here, but I want to
I'm trying to work on a new project parsing some JSON data for a

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.