I am trying to retrieve a JSON from an external API using Volley. Here is my code
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
final TextView mTextView = findViewById(R.id.testreq);
RequestQueue queue = Volley.newRequestQueue(this);
String url = "https://horoscope-free-api.herokuapp.com/?time=today&sign=cancer";
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// Display the first 500 characters of the response string.
mTextView.setText("Response is: "+ response.substring(0,500));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mTextView.setText("That didn't work");
Log.d("Error", error.toString());
}
});
queue.add(stringRequest);
}
It seems like the response is done but I am getting this error
E/Volley: [277] BasicNetwork.performRequest: Unexpected response code 500 and when I ran a test on the API in https://apitester.com/ It tells me its passed and I get this error
Response Headers HTTP/1.1 500 Internal Server Error Connection: keep-alive Date: Sat, 10 Nov 2018 19:56:18 GMT Server: Apache Transfer-Encoding: chunked Content-Type: application/json Via: 1.1 vegur
Any ideas how to solve this? Is it the API or is it me?