1

I have a server endpoint which validates some data and return true/false if the data validation has no errors.

So which Version would be correct or more suitable for a RESTful webservice?

POST https://server.de/validate

POST data in body and return HTTP status code 200 if validation had no errors or

GET https://server.de/validate?=data

Send data in header or query parameter and return true/false in the response (Status code 200 would be returned after a correct request, independent of the data validation).

Gobliins
  • 3,848
  • 16
  • 67
  • 122
  • 4
    Its not ideal to have verbs in the uri as validate in rest terminologies.. This is more like procedural oriented.. You have to idenitify this in terms of resource and convert this to get and post on the resource which you have to validate... – Janier Jan 16 '17 at 09:27
  • True, i have called it `validation`. – Gobliins Jan 16 '17 at 09:43
  • 1
    Neither URI is Restful. Neither URI is acting as a *resource* which the document you're transferring to it is a representation. Rather, the endpoints are acting as processors which transform the data being sent to them. You should either rethink your URI structures *completely* or stop calling what you're doing REST. – sisyphus Jan 16 '17 at 11:50

1 Answers1

3

You should always use POST if the information is sensitive.

Read This thread for more information there are many similar question with yours if you search:

Edit/Update: a good source for seeing the difference

Community
  • 1
  • 1
  • 1
    even if we have https? – Gobliins Jan 16 '17 at 09:37
  • 1
    Yes, but it all depends of course depends from case to case , there are very good examples in the question i linked, reading through them you get a better picture of what you should implement. Personally I prefer the POST methods, it is less prone to malicious users and "errors", for example, a GET method can be emailed around as a link by a malicious user etc. @Gobliins –  Jan 16 '17 at 09:43