Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RESTful URL for "Activate"

Tags:

rest

http

url

api

I have a resource (project) which can be activated and deactivated.
What's the most RESTful URL endpoint for this purpose?

Right now I'm thinking about /projects/:id/activate and /projects/:id/deactivate, but I don't think that's very RESTful.
In addition, I'm not certain what HTTP method to use.

Can you provide some pointers?
Thanks!

like image 603
Neta Avatar asked Jan 14 '16 13:01

Neta


People also ask

How do I find my REST API URL?

The default URL to access the messaging REST API is: https://localhost:9443/ibmmq/rest/v1/messaging . If the host or port is changed from the default, or if HTTP is enabled, you can determine the URL by using the dspmqweb command.

What is RESTful service URL?

A RESTful web service request contains: An Endpoint URL. An application implementing a RESTful API will define one or more URL endpoints with a domain, port, path, and/or query string — for example, https://mydomain/user/123?format=json . The HTTP method.


1 Answers

I know I am a bit late but maybe this might be useful for others.

You can create a noun from your operation and use it as sub-resource: activate -> activation

Now you can use POST and DELETE on this sub-resource.

For example:

POST /projects/:id/activation       <-- activate project
DELETE /projects/:id/activation     <-- deleting the activation = deactivate

This pattern can work quite well for operations that toggle between on/off state of something.

like image 126
micha Avatar answered Sep 28 '22 08:09

micha