Should I use the GET or POST method when sending information to a server in the body of the HTTP request? There are no query parameters appended to the URL, the server will inspect the body of the request for what it needs.
GET extracts parameters from the request URL. POST extracts parameters from the request body.
So you need POST.
A nice description and interesting discussion on the topic:
http://thinkvitamin.com/code/the-definitive-guide-to-get-vs-post/
POST should be used if you are not planing on using the query string.
Related
I am new to HTTP requests (GET, POST, PUT, ETC.) and I am having some issues understanding the "anatomy" of these procedures.
What exactly is the difference between the body and the data? Are they the same thing? Or are headers the same thing as the param? When authentication takes place, are the username and password params or headers or does it vary from API to API? Any help is greatly appreciated. Are there any tutorials or reads you recommend to better understand how to deal with HTTP requests?
Thank you!
Based on This article and some points of others, you could find out about differences between HTTP header & HTTP parameter ,and and also Body:
Header:
meta data about the request
HTTP Headers are NOT part of the URL
if it's information about the request or about the client, then the header is appropriate
headers are hidden to end-users
globally data
restrict Dos-attack by detecting authorisation on it's header, because a header can be accessed before the body is downloaded
Param:
the query params are within the URL
like this "tag=networking&order=newest"
if it's the content of the request itself, then it's a parameter
The product id and requested image size are examples of "some detail" (or parameter) being supplied as part of the content of a request
parameters can be seen by end-users (query parameters) on URL
Body:
data of business logic
important information
unlike body, proxy servers are allowed to modify headers
data in specefic kinds of requests
you can pass token by body as encoding & decoding in servers
For a full and correct understanding of these questions, RFC2616 recommend by Remy Lebeau is worth reading.
What exactly is the difference between the body and the data?
If you are reading some blog, the body (HTTP body) is be used to transfer data (probably in JSON format). The body carries data, in another way, you get data from body.
Are they the same thing?
So they are not same at all.
Or are headers the same thing as the param?
Header (HTTP header) is related to body, they are part of the HTTP message.
As param, it's usually refer to http request param, which usually looks like the following part of the question mark
url?paramName=paramValue¶mTwo=Value2
When authentication takes place, are the username and password params
or headers or does it vary from API to API?
They vary for different API's, normally not in param, probably in body of a post request.
Again, start from the RFC2616 would be a good choice.
data is not a HTTP specific term. data can be anything.
a 'parameter' is also not a HTTP specific term. Many web frameworks might consider parameters everything behind the ? in a url, but this is not an absolute truth.
usernames and passwords sometimes appear in the request body, sometimes in headers. In web applications they typically are in the request body, but certain types of authentication systems place them in the Authorization header.
I want to send a HTTPS Post Request to a server. The content should be a JSON Expression.
For LotusScript I have not found a solution. A code snippet which solves the problem is highly welcome.
One way to solve this is through LS2J or if your client runs on windows, you could use the xmlhttp object an example is here
I am calling webservice which takes two parameters like category and salt then provide the json output with constructed url but url is not working. PFA url
Service Url:
http://qalisting.corelogic.com/ChaseListingServices/v1.5/test
constructed URL: http://qalisting.corelogic.com/ChaseListingServices/v1.5/listings/search/test/0/4e9c00b32794edfeba257aa0c74f500b
Looking at the error message on your constructed URL, the Service needs to be called using a POST and not a GET Request.
Responding to your comments: it's not the URL which is the problem but how it is called. When you follow a link, such as the one you posted - the browser sends it as a GET request. The service is expecting the JSON arguments as part of the "body" of a POST request. This must be done programmatically.
I wish to get the complete url of file being set by server through its http-header(response). I am doing some sort of packet filtering. Is it possible to generate complete url from http response header.
No, it's not possible. You need the actual HTTP request.
I want to encode a URL such that it sends a POST request to a server. is that possible? and if so, how? I have searched around and mostly found that appending parameters to a url only sends them as parameters for GET request. is there a way to do that for POST request?
basically, i am trying to implement a CSRF (not for malicious but testing purposes) and i want to be able to send a POST request to a server by encoding my url.
GET and POST are HTTP methods. In GET the request parameters are taken as query string in the request URL. In POST the request parameters are taken as query string in the request body.
So you need to instruct whatever tool you're using to pass the parameters through the request body instead of the request URL along with a HTTP method of POST instead of (usually the default) GET.
Either way, the parameters just needs to be URL encoded anyway. There's no difference for POST or GET, unless you're setting the content encoding to multipart/form-data instead of (usually the default) application/x-www-form-urlencoded.
If you give more details about what programming language and/or library and/or framework you're using, then we may be able to give a more detailed answer how to invoke a HTTP POST request.
No.
The method is not part of the Url. You'd have to make the request in such a way that it uses the post method.
You didn't mention any details, but if it's from inside a document in the browser, you can either use a form:
<FORM action="someUrl.htm" method="post">
You can make a link that will send the form by javascript:
<form action="http://www.example.com/?param=value" method="post" id="someForm">
link
</form>
or an XmlHttpRequest with javascript:
var xhr = new XMLHttpRequest();
xhr.open("POST", url);
...