I have a web app + database hosted in python which I have tested and works for creating, logging in and logging out user. Now I'm trying to make the requests in my android application written in java. However, I keep getting 308 error.
Here is my RegisterActivity.java
private void register() {
// Get headers, method and url to be used in the request
final String user = username.getText().toString();
final String pass = password.getText().toString();
Map<String, String> userObject = new HashMap<>();
userObject.put("username", user);
userObject.put("password", pass);
final int method = Request.Method.POST;
final String url = "https://tddd80-app-joneri.azurewebsites.net/user";
// Create request
GsonRequest request = new GsonRequest(Request.Method.POST, url, userObject,
response -> System.out.println("Success! Response: " + response),
error -> System.out.println("Error with request: " + error.getMessage());
// Add the request to the Volley request queue
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(request);
and this is the most important part of GsonRequest which should parse JSON into string:
public class GsonRequest extends Request<String> {
private final Map<String, String> headers;
private final Response.Listener<String> listener;
public GsonRequest(int method, String url, Map<String, String> headers,
Response.Listener<String> listener, Response.ErrorListener errorListener) {
super(method, url, errorListener);
this.headers = headers;
this.listener = listener;
}
Any help is appreciated!