This question already has answers here:
What is the difference between POST and GET? [duplicate]
(7 answers)
Closed 4 years ago.
I am using android studio and got me wondering what's the difference of using post and get method request. I know when we use GET METHOD as a request in front end, we would see the request parameters in the url. But in android there aren't any url, so what difference does it make when using post method and get method in android ?
Well, The main difference is GET passes request parameter in URL string while POST passes request parameter in request message body which makes it more secure way of transferring data from client to server in http protocol
But if you look more into it, there are any other difference:
First
GET is used for data retrieval only. you can refine what you get from GET METHOD but it is as read only.
While POST is used for send data, But it only like a way to break the simple workings of HTML because you are neither guaranteed of anything that is happening, while it can fetch, send, or delete a data.
Second
GET request can only pass limited amount of data while POST method can pass large amount of data to server
Third
GET is mostly used for view purpose (e.g. SQL SELECT) while POST is mainly use for update purpose (e.g. SQL INSERT or UPDATE).
Fourth
the result of POST may not result in an actual page.
and Lastly
If you have a HIDDEN inputs in form then submitting a GET request reveals that HIDDEN inputs. (PHP GET and POST)
Related
so i am using volley to connect to a backend and for some reason they need the form request data to be in a certain order the server wont accept it. unfortunately no matter how i put my data into the hashmap when overriding getParams they always come out in the same, incorrect order causing me to be unable to make a request. is there a way for me to order it, or just create my own string and send that? thanks
This question already has answers here:
When should I use GET or POST method? What's the difference between them?
(15 answers)
Closed 9 years ago.
Can anyone tell me difference between Httpost and Httpget method.Httpclient can execute POST and GET method.Please explain the difference between 1 and 2nd method
1.)httpclient.execute(httppost)
and the other one
2.) httpclient.execute(httpget)
In Http Get Method all the values that user sends to the server, embedded with the URL that we send as the request, where a third party can easily watch it. If I say it more technical way, by using the HTTP GET method, we are sending user details in the header part of the request not in the body.
source
Where as in Http Post method we transfer confidential data to a different location by using HTTP. The reason is the content goes inside the body, not with the header as in GET method.
source
You can also refer android developers website
The Apache HTTP Client supports all the commands that are supported by HTTP, such as GET, PUT, POST, DELETE, TRACE, OPTIONS & HEAD.
Most well-known are GET & POST, where GET is used to fetch a resource from the URL and POST is used to store data at a URL. There are official ways in how the different methods should be used, especially when creating a REST API, but in real life most boil down to the GET and the POST.
For a full discussion of the different methods you can read RFC2616 describing the HTTP: http://www.faqs.org/rfcs/rfc2616.html
I have one android application to be made.
In the Registration process i have to fill in two fields
Phone number
Name
Along with these two fields i have to also send my deviceid, current time and OS version dynamically.
How can i do so?
My Web Service is
http://frapp.badoniya.com/webservices/register.php?username=Vijay%20&deviceid=12345&mobile=98XXXXXXXX&platform=Android&os_version=4.0
Please give me a step wise solution.
Because i am very new in programming.
Use an AsyncTask to achieve what you are looking for. Here are few examples on how to use an AsyncTask, Send a GET request and Sending a POST request. For this scenario you must send a GET request.
GET Request
Example 1
Example 2
POST Request
Example 1
AsyncTask
Example 1
you have to use an AsyncTask and inside the async task you can use HTTPPost or HTTPGet requests to call a webservice using parameters
My client is an Android app and my service is an asp.net web api. I’m the only one using my service. I am trying to duplicate, in the Android-REST world what I am already doing in the Microsoft Windows Phone 7/ WCF SOAP world. I have numerous methods that both receive complex objects and return complex objects.
The WCF-SOAP world is simple. You can pass any complex arguments you want and return any complex results you want. Logically, it’s just a Remote Procedure Call.
But when I post questions about doing the same thing in REST, I’m told I should limit my services into GET, PUT, POST, and DELETE only. And that I should only do what is “proper” according to RFC2616. Some speak of this in almost a religious manner.
Forgeting about the religion, what’s wrong with using a GET for everything? Or what’s wrong with using a POST for everything? What I do does not fall into the simplistic RFC2616 categories. For instance I’m passing a thousand legs of a trip taken in a car and I’m getting back another version of that trip with erratic GPS errors smoothed out. Or, I’m sending a conversation in english and getting that conversation back in German.
In the android client I have the objects I want to send over HTTP already serialized into json strings by using Google-GSON. So my questions are…
How can I send these json strings to my REST Service as arguments in either GET or POST?
Is it possible and feasible to use just all GETs (or all POSTs) for all of my calls to my REST Service and how do I do that?
I have a more pragmatic question about this posted at sending a json string in a http url as I can’t find any examples anywhere of sending json strings over http GET or POST.
Thanks, Gary
Using the good HTTP verb is very usefull to simply know what to do when you request failed (for example) or just to do some specific stuff. If you sent a POST request, it's implicitly suppose that you have to parse your resource in order to obtain a stream which be sent via the request's body. In other hand, when you are retrieving data via GET, it's suppose that the request is gonna be sent back to you as a stream that you will mapped to your model, pojo, or anything else.
I can suggest you to use library such as RESTDroid. You can send POJO and receive POJO. It's a "resource oriented" library, so you can know at any moment if a particular local resource is remotely syncronized. Data persistence between local and remote is automatically handles.
RESTDroid is alpha released. You can have a look to RoboSpice. It's a powerful library to manage REST call but it's up to you to manage the persistency between local and remote resources.
1) The WCF-SOAP world is simple. You can pass any complex arguments you want and return any complex results you want. Logically, it’s just a Remote Procedure Call.
- IN REST:"You can pass any complex arguments you want and return any complex results you want too.
2a) Forgeting about the religion, what’s wrong with using a GET for everything?
In SOAP services WCF/or classical you are wrapping all requests into http POST so using single verb would end up to SOAP or - don't even think about it - your own communication protocol:-D
2b) You can technically compose GET request with non empty body - most of the servers ignore it by default though and it would be technically problematic to read it..
the other part of the question is answered by Pcriulan above
First of all, the strategy that i have at the moment was achieved by searching here in stackoverflow, but by some reason, the "next step" was never mentioned here..
So i'm currently developing an android app that needs to fetch some data
from a remote database. I've searched in the web and at the moment i'm
able to get the data i want through a http request (rest webservice +
json response). My problem is, i can only fetch data of one database
query to my app in the same database session..
I wanted some strategy where i could send the http request, and them
perform 2 or 3 database querys and return them back to my app, without
the need to open 2 or 3 times a database connection, or sending one
http request for every query.
I know i can do some tricky manipulations with the json response, like
putting all the database query's response separated by some marks i
choose, but i was looking for some clean solution.
Can you help me achieve this pls?
Thanks
Unless you create some combined data structure which is the result of all the queries and then convert it to a JSON string, then your suggestion is the only other way to go, I feel. The combined data structure can then be recreated from the JSON received at the client end.