2

I have a REST API endpoint for creating an empty object. What is the "standard" url scheme for this GET method? I'm currently using a factory in an angularjs app to make the call to the server.

Right now I have the following scheme:

GET 
Item/new/

My $resource:

 ngServices.factory("TESTfactory", function ($resource) {
                    return $resource("testNewItem/new", {}, {
                            create: {method: 'GET'}
                        }
                }

A successful call to the above resource:

$scope.newItem = TESTfactory.newItem.create();

Any other suggestions would be much appreciated.

I've looked at the following links, which did not specifically list a url scheme for getting empty objects:

  1. REST API Overview
  2. Quick Reference section in this doc
miniscem
  • 327
  • 1
  • 5
  • 14

1 Answers1

2

A GET method should never create something. GET is supposed to be nullipotent, which means that it should have no side-effects. Creating a resource is certainly a side effect.

So, the standard http call would be

POST 
Items/create

or

POST
Items/new

or better yet just

POST
Items/
Tui Popenoe
  • 2,098
  • 2
  • 23
  • 44
Nick Bailey
  • 3,078
  • 2
  • 11
  • 13
  • 4
    I believe the OP wants a *template* object - as in, his repository suffers no change, no resource is created; he wants a new instance that provides the model. – OnoSendai Mar 27 '15 at 19:07