Commit 781f86aa authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Better indenting and blank lines to make things more readable

parent 0ffd880d
Pipeline #49 skipped
# AWIT JSON Format Standard
# HTTP Methods
Make sure during implementation you read [RFC7231](https://tools.ietf.org/html/rfc7231).
## POST
The POST verb is most-often utilized to **create** new resources. In particular, it's used to create subordinate resources. That is, subordinate to some other (e.g. parent) resource. In other words, when creating a new resource, POST to the parent and the service takes care of associating the new resource with the parent, assigning an ID (new resource URI), etc.
......@@ -17,11 +19,12 @@ POST is neither safe nor idempotent. It is therefore recommended for non-idempot
* 404 (Not Found)
* 409 (Conflict)
* If resource already exists.
### Examples
* POST http://www.example.com/customers
* POST http://www.example.com/customers/12345/orders
## GET
The HTTP GET method is used to **read** (or retrieve) a representation of a resource. In the “happy” (or non-error) path, GET returns a representation in XML or JSON and an HTTP response code of 200 (OK). In an error case, it most often returns a 404 (NOT FOUND) or 400 (BAD REQUEST).
......@@ -42,6 +45,7 @@ Do not expose unsafe operations via GET—it should never modify any resources o
* GET http://www.example.com/customers/12345/orders
* GET http://www.example.com/buckets/sample
## PUT
PUT is most-often utilized for **replace** capabilities, PUT-ing to a known resource URI with the request body containing the newly-replaced representation of the original resource.
......@@ -63,11 +67,13 @@ If, for instance, calling PUT on a resource increments a counter within the reso
* 404 (Not Found)
* If ID not found or invalid.
### Examples
* PUT http://www.example.com/customers/12345
* PUT http://www.example.com/customers/12345/orders/98765
* PUT http://www.example.com/buckets/secret_stuff
## PATCH
PATCH is used for **modify** capabilities. The PATCH request only needs to contain the changes to the resource, not the complete resource.
......@@ -111,8 +117,10 @@ There is a caveat about DELETE idempotence, however. Calling DELETE on a resourc
* DELETE http://www.example.com/bucket/sample
# Format
## The 'status' field
The purpose of this field is to signify the status of the action just performed.
......@@ -123,7 +131,7 @@ The purpose of this field is to signify the status of the action just performed.
|fail|There was a problem with the data submitted, the 'data' field must contain additional information|message||
|error|An error occurred in processing the request, the 'data' field must contain additional information in a 'message' field and may contain an additional 'data:code' and 'data:errors' (array) fields|message|data:code,data:errors|
## Example success
### Example success
For a brief status message one could use...
```json
......@@ -166,8 +174,7 @@ For a successful status which returns a single result...
}
```
## Example for a fail
### Example for a fail
Failures must have a mesasge field...
```json
......@@ -192,7 +199,7 @@ Or it can be verbose...
}
```
## Example for a error
### Example for a error
An error can be brief...
```json
......@@ -224,12 +231,16 @@ The purpose of this key is to give a quick status message as to the result of th
The format of this keys data is plain text.
## The 'data' field
This field contains result data. Either a 'result' key or a 'records' key.
See the 'status' field definition above for examples.
# Acknoledgements
<div xmlns:cc="http://creativecommons.org/ns#" about="http://www.restapitutorial.com/lessons/httpmethods.html"><a rel="cc:attributionURL" property="cc:attributionName" href="http://www.RestApiTutorial.com">RestApiTutorial.com</a> / <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment