Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which REST operation (GET, PUT, or POST) for validating information?

My users enter a few information fields in an iOS app. This information must be validated on my server, which has a RESTful API. After validation the UI of the iOS app changes to indicate the result.

Neither GET, PUT, or POST seem to be appropriate, because I'm not getting a resource, and neither is a resource created or updated.

What is the best fitting REST operation to implement this validation?

like image 712
meaning-matters Avatar asked Aug 13 '13 20:08

meaning-matters


People also ask

Does REST API use Get or Post?

GET requests should be used to retrieve data when designing REST APIs; POST requests should be used to create data when designing REST APIs.

What do you validate in REST API?

The Validate REST Request filter enables you to validate the following aspects of a REST request: The HTTP method used in the request. Each of the path parameters against a set of restrictive conditions called a request parameter restriction. Each of the query string parameters against a request parameter restriction.

What is post operation in REST API?

The POST method is used to request that the origin server accept the entity attached in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. It essentially means that POST request-URI should be of a collection URI.


1 Answers

I use the same scenario as you and use PUT for it. You have to ask yourself: "when I send the same request twice, does this make a different state on server?" If yes, use POST, if no use PUT.

like image 180
Lukas K Avatar answered Oct 23 '22 23:10

Lukas K