Search code examples
androidjsonweb-serviceshttpconnection

How to send a JSON object(in get method) over Request with Android?


I want to send the following parameter

 data={"method": "category", "parameter": {"id":20, "language":"en"}} 

to a web service How can I do this from android for get method? i tried but did not work.


Solution

  • your JSON is created like this :

     try {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("method", "category");
                    JSONObject jsonObject1 = new JSONObject();
                    jsonObject1.put("id", 20);
                    jsonObject1.put("language", "en");
                    jsonObject.put("parameter",jsonObject1 );
                } catch (JSONException e) {
                    e.printStackTrace();
                }
    

    Now you can add this in your request with key as "data"