Reputation: 776
I'm able to fetch JSON information from a URL for a few minutes, however eventually it'll give me "Unexpected response code 429". The link is from Steam, I'm wondering if this is a problem with Volley or Steam? Here is my current implementation as it could be possible I'm missing something from my code.
RequestQueue queue = Volley.newRequestQueue(this);
// Request a string response from the provided URL.
JsonObjectRequest stringRequest = new JsonObjectRequest(Request.Method.GET, retrievalURL, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
int indexOfWear = listOfWears.indexOf(wear);
Map<String, String> itemInList = listWearsAndPrices.get(indexOfWear);
if (response.getBoolean("success")) {
itemInList.put("Price", response.getString("lowest_price"));
} else {
// If price is not possible
itemInList.put("Price", "Item Unavailable");
Log.e("tag", "Item unavailable unreached");
}
// Update view
adapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
/**
* TODO
* CHECK FOR INTERNET CONNECTION
*/
int indexOfWear = listOfWears.indexOf(wear);
Map<String, String> itemInList = listWearsAndPrices.get(indexOfWear);
itemInList.put("Price", "Item Unavailable");
adapter.notifyDataSetChanged();
}
});
// Add the request to the RequestQueue.
queue.add(stringRequest);
Upvotes: 1
Views: 2748
Reputation: 5705
429 response code means
Too Many Requests
The user has sent too many requests in a given amount of time ("rate limiting").
Probably api you are trying to hit is limited to number of hits you can make in day or certain amount of time.
Upvotes: 1