How to send information to the server?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
14 views
The question is, if we accept the information from the database on the server is clear as we pass a get request with parameters, where the parameters are processed and transmit the info back (even though I have data reception on the client and the problem, but now not about it).
How to send information to the database if a post request means (as I understand) we have a form that we fill and need to use the abstract body().
Can I put a request to update info and create a new one?
by | 14 views

2 Answers

0 like 0 dislike
I think you hardly ineteresuet sending web forms.

Send data in JSON format by POST method (create) or PUT (change). From the Android the best solution would be to Retrofit. Well, the server of your choice. Most frameworks already have a built-in support for REST API and it is better to use.
by
0 like 0 dislike
You can use the library okhttp3, very simple and I think will suit you
POST has PUT the queries etc, all written in a single small method, if desired.

MOSPRIME PUT request using OkHttp3

public String ServerQuery() throws IOException { OkHttpClient client = new OkHttpClient(); String json = getJson(); RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json); Request request = new Request.Builder() .url(getUrl()) .put(body) .build(); Response response = client.newCall(request).execute(); return response.body().string(); } return null; }
by

Related questions

0 like 0 dislike
1 answer
asked Apr 12, 2019 by prumin
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,457 users