post vs put

PUT method is call when you have to modify a single resource, which is already a part of resource collection. POST method is call when you have to add a child resource under resources collection.

Can POST be used instead of put?

Can I use POST instead of PUT method? Yes, you can. HTML forms, for example, use POST for all writes.

Why is POST better than put?

Another important difference between the methods is that PUT is an idempotent method while POST is not. For instance, calling the PUT method multiple times will either create or update the same resource. On the contrary, multiple POST requests will lead to the creation of the same resource multiple times.

Why is POST more secure than put?

POST is more secure than GET for a couple of reasons. GET parameters are passed via URL. This means that parameters are stored in server logs, and browser history. When using GET, it makes it very easy to alter the data being submitted the the server as well, as it is right there in the address bar to play with.

Is POST more secure than put?

GET is less secure compared to POST because data sent is part of the URL. So it’s saved in browser history and server logs in plaintext. POST is a little safer than GET because the parameters are not stored in browser history or in web server logs.

What is HTTP PUT?

The HTTP PUT request method creates a new resource or replaces a representation of the target resource with the request payload.

Is it OK to use POST to get data?

Off course it is bad practice to use POST for getting data as POST is for creating resources in system not getting them. I have an API call that requires a lot of parameters and it’s basically a Read action.

Can I use GET instead of put POST to make a new resource?

Can I use GET request instead of PUT to create resources? You can, but the only way to pass data in a GET request is by the URL itself.

When to use POST vs put vs PATCH?

When building RESTful Web-Services the HTTP method POST is typically used for resource creation while PUT is used for resource updates. While this is fine in most cases it can be also viable to use PUT for resource creation. PATCH is an alternative for resource updates as it allows partial updates.

Can http put create a new record?

Http “Put” method to update a record and insert new one simultaneously.

Should Put return updated object?

you should have RowVersion in every record that can be updated (to avoid the lost update problem)you should always return a new copy of the record after PUT (to get the new RowVersion).

Does put have a body?

If the request has a Content-Length header, then it has a body. It may be an empty body, but still a body. In contrast to a request with no Content-Length header, which has no body at all, not even an empty one. So yes, a PUT request, technically, strictly, has to have a body.

Why POST method is not safe?

Since POST is not a idempotent method, calling it multiple times can result in wrong updates. What would happen if you sent out the POST request to the server, but you get a timeout.

How secure is POST?

Yes, POST is better than GET because POST data is not usualy logged by a proxy or server, but it is not secure. To secure a password or other confidential data you must use SSL or encrypt the data before you POST. Another option would be to use Digest Authentication with the browser (see RFC 2617).

You Might Also Like