tags:

views:

27

answers:

1

Suppose I have an HTTP API with two methods: read and write.

So I could do

POST url: /api/read
body:
<method>customers.list</method>
<args>
 <area_code>90210</area_code>
</args>

POST would be the method for both read and write. I know it's not RESTful, but I can update it on the fly on the server side without having to change the client's code, and even have a GET /api to retrieve all methods available, thus in a way have a mechanism to document the API on the client side.

What's so wrong with this approach, other than not being cache-able?

Thanks!

+1  A: 

If something really simple solves your task - that's ok.

In your sample, I am not sure how common clients are going to send body in GET request.

BarsMonster
yeah, my bad - it's either in the query string or they're both POSTs
sardaukar
Then yes, this is 100% legit if it solves your task.
BarsMonster
why don't people do this more often, then? :)
sardaukar
If everything would be as simple as possible - 90% of developers would be sitting without job. ;-)
BarsMonster