Reputation: 197
I am trying to create a simple registration page for my android app. I am passing parameters with URL String and Storing those parameters in Database. Whenever i try to use string directly in browser the data is added to database without any error. However, When i try to pass data from Android Volley i am getting HTTP Error 409.
I have checked everything and still confused why this error is appearing only when i try to run url string from android app.
URL String:-
http://myurl.com/api/register.php?name=ahmed&[email protected]&password=12345&membertype=Artist&joindate=24-Feb-2019
Java Code:-
JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, urlFinal, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// display response
Log.d("Response", response.toString());
uploadImageToServer();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("Error.Response", error.toString());
hideDialog();
}
}
);
Upvotes: 0
Views: 190
Reputation: 129
First you need to understand about 409,
Explain here :- https://httpstatuses.com/409
And try to solve this on Server side where this Conflict issue occur.
And I recommend you to use URL Encoding before sending things in url, Which is perform by : Either by,
String query = URLEncoder.encode("apples oranges", "utf-8");
String url = "http://stackoverflow.com/search?q=" + query;
or By
String uri = Uri.parse("http://...")
.buildUpon()
.appendQueryParameter("key", "val")
.build().toString();
Which make your URL more compatible.
Or for More Better ways, There is an Library which i personally recommend to any android developer who love Light weight Volley for Api Integrations.
https://github.com/Lib-Jamun/Volley
dependencies {
compile 'tk.jamun:volley:0.0.4'
}
Cool Coding.
Upvotes: 1