Motivation

REST

A RESTful collection interface

Collection Methods and Status Code Returns

Method Code Result
GET 200 Success
POST 201 Success (Created)
PUT 202 Success (Updated)
DELETE 204 Success (No Content)

Interface to a single item in a collection

Method Code Result
GET 200 Success
POST 202 Success (Updated)
PUT 201 Success (Created)
PUT 202 Success (Updated)
DELETE 204 Success (No Content)

Query Strings

Rest Request 1

POST /classScedService HTTP/1.1
<openClassRequest term="SUM2016" class="CS1520"/>

Responds with…

HTTP/1.1 200 OK

<openClassList>
	<class number="CS1520" time="930" />
	<class number="CS1520" time="1430" />
</openClassList>

Rest Request 2

POST /classScedService HTTP/1.1

<registerRequest>
	<class number="CS1520" time="1430" />
	<student id = "alice"/>
</registerRequest>

Response:

HTTP/1.1 200 OK
<registration>
	<class number="CS1520" time="1430" />
	<student id="alice"/>
</registration>
HTTP/1.1 200 OK

<registrationFailure>
	<class number="CS1520" time="1430" />
	<student id="alice"/>
	<reason>Full Class</reason>
</registrationFailure>

Rest Request 3

GET /classes/SUM2016?status=open HTTP/1.1

Response:

HTTP/1.1 200 OK

<openClassList>
	<class id=123 number="CS1520" time="930" />
	<class id=124 number="CS1520" time="1430" />
</openClassList>

Rest Request 4

POST /registration/124 HTTP/1.1

<registerRequest>
	<student id = "alice"/>
</registerRequest>

Response:

HTTP/1.1 201 CREATED Location=/registrations/124/registration44

<registration>
	<class id=124 number="CS1520" time="1430" />
	<student id="alice"/>
</registration>
HTTP/1.1 409 CONFLICT

<openClassList>
	<class id=123 number="CS1520" time="930" />
</openClassList>

Alright, NOW we’re RESTful, right?

Something something theory and practice