Questions tagged [jsonobjectrequest]

JsonObjectRequest—A request for retrieving a JSONObject response body at a given URL, allowing for an optional JSONObject to be passed in as part of the request body.

Volley provides the following classes for JSON requests:

JsonArrayRequest—A request for retrieving a JSONArray response body at a given URL.

JsonObjectRequest—A request for retrieving a JSONObject response body at a given URL, allowing for an optional JSONObject to be passed in as part of the request body.

Check here for more Details

TextView mTxtDisplay;
ImageView mImageView;
mTxtDisplay = (TextView) findViewById(R.id.txtDisplay);
String url = "http://my-json-feed";

JsonObjectRequest jsObjRequest = new JsonObjectRequest
        (Request.Method.GET, url, null, new Response.Listener<JSONObject>() {

    @Override
    public void onResponse(JSONObject response) {
        mTxtDisplay.setText("Response: " + response.toString());
    }
}, new Response.ErrorListener() {

    @Override
    public void onErrorResponse(VolleyError error) {
        // TODO Auto-generated method stub

    }
});

// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
131 questions
12
votes
6 answers

How to send json array as post request in volley?

I am using volley for json parsing. I want to send some data using POST to server side. I am trying to send .Now can any one tell me that how can i send filter array to server? Following is my snippet code. i tried also Hashmap and Jsonobject. but…
chris
  • 649
  • 3
  • 12
  • 34
6
votes
3 answers

Android Volley, JsonObjectRequest but receiving JsonArray

So I am using a JsonObjectRequest to send up a JsonObject to a rest call, but its returning a JsonArray rather then a JsonObject. Its giving me an error saying that it cannot parse the results from the JsonObjectRequest, but if I use…
Pandamonium99
  • 164
  • 1
  • 10
6
votes
1 answer

Android Volley JsonObjectRequest returns same response every time on mobile data

I am using Volley JsonObjectRequest to get data from server. code snippet: JsonObjectRequest jsObjRequest = new JsonObjectRequest (Request.Method.GET, url, null, new Response.Listener() { @Override public void…
Priyank Patel
  • 11,271
  • 8
  • 59
  • 79
4
votes
2 answers

Volley's StringRequest is not returning JSONObject

The code below is going to implement a simple online login system. The php script path is defined in constant authenticationURL (line 34 in MainActivity.java). It was tested with Postman and works as it should. Also the loginButton and its onClick()…
3
votes
1 answer

Methods aren't being called in a chronological order

I am trying to call functions in a chronological order but functions parseJSONTwo() seem to be executing before function parseJSON() (both functions just fetch JSON data from URL) package com.example.rechev; import…
Skity
  • 119
  • 9
3
votes
1 answer

How to force the code to go to onErrorResponse in Volley JsonObjectRequest

A crash is reported in Volley JsonObjectRequest and exactly in its onErrorResponse block. I cannot change the webservice output to test onErrorResponse block and it's important to debug this code block. Can anyone tell me how to force the code to go…
Alireza Noorali
  • 3,469
  • 2
  • 23
  • 60
3
votes
1 answer

Volley Get Request: onResponse is never called

im pretty new to Android Studio and I'm trying to build a Get Request using Volley, the Server response is a JsonObject. I tested the code with breakpoints but I wonder why I don't jump into onResponse or why it won't work. Here's my Code of the Get…
user7908423
3
votes
5 answers

How to post request parameters when using JsonArrayRequest in Volley

I am newbie to Json parsing. I am trying to read a json data using JsonArrayRequest but I am little confused in sending parameters and use POST method.In case of JsonObjectRequest i can send the method type,url,params but In JsonArrayRequest how to…
user1932583
  • 55
  • 1
  • 1
  • 5
2
votes
1 answer

How to send JSONObject to server as form-data using Volley

I'm going to send a JsonObjectRequest to the server as form-data using Volley Library. I Checked similar questions. none of them covers my problem. This is Postman ScreenShot of the exact request that I need: This is My JSONObject named myKey which…
Alireza Noorali
  • 3,469
  • 2
  • 23
  • 60
2
votes
1 answer

Volley POST request coming back null with headers and body

I'm having an issue where onResponse(JSONObject response) keeps coming back null. I have logged the JSONObject.toString being passed as the body in the request (POST), pasted into Postman, and it works; I get a valid response from the server(JSON…
jaypee
  • 84
  • 4
2
votes
1 answer

How to stop receiving data from a web server?

I have an Activity that receives and displays information from the web server and saves it to the database and, if it has already received the information once, it will read from the database. There is no problem running the program, only when the…
mohammad
  • 23
  • 1
  • 6
2
votes
1 answer

How to get string response from php using android volley JsonObjectRequest?

ctually when we call API and send request in JSON format we are expecting response also come into JSON format. But here back end team sending me response in String format therefore my onErrorResponse () method get called. Here my status code is 200.…
2
votes
3 answers

How to send {data:[{id:"11:}]} request to server in using volley and pass ObjectRequest in body

I want to pass {"data:"[{"id":"12"}]} in volley request body. private void reqrej(final String currentLat) { String insertData = "http://www.xxxxxxxx.com/makeinforequest.php"; final StringRequest stringRequest = new…
2
votes
2 answers

Multipart Request Using Android Volley (uploading multiple images to server)

This is the gist iam refering for uploading images to the server https://gist.github.com/anggadarkprince/a7c536da091f4b26bb4abf2f92926594 But iam using TedPicker OnMultiImageSelectedListener to select multiple images …
Sooraj S
  • 281
  • 5
  • 13
2
votes
1 answer

how to parse JSON using Volley

i am using volley library for post data over api...in here the Content-Type is "application/json" .... how can i implement this type of json data : URL: Base_URL + dorequisition { "submitted_by_employee_id": 1, "name": "Technolive SF for TC", …
Tamzid Babu
  • 89
  • 1
  • 11
1
2 3
8 9