HTTP Verbs

HTTP Verb Cheatsheet

Quick Summary

POST - The URI specifies the resource that the supplied entity should be created under

PUT - The URI specifies the entity that the supplied data shoud replace

PATCH - The URI specifies the entity that the supplied data shoud be merged with

GET - The URI specifies the entity that should be retrieved (no body content)

DELETE - The URI specifies the entity that should be deleted (no body content)

FeatureGETPOSTPUTDELETE
Request has a bodyNOYESYESYES
Response has a bodyYESYESNOYES
SafetyYESNONONO
Idempotent1YESNOYESYES

Examples

title: POST
icon: 
collapse: true


Create item using body data
~~~py
URL = "https://###/api/projects?keys={params}"
BODY = {
	"projectId": "1234-5678-etc",
	"attributes": {
		"projectName": "Example",
		"attribute2": "Value2",
	}
}

RESPONSE = 201 Created
~~~

Note: Any logic handling should be done via the query string params. The `BODY` should exclusively contain the entity that is being created
title: PUT
collapse: true

Replace item at {projectId} with body data
~~~py
URL = "https://###/api/projects/{projectId}?keys={params}"
BODY = {
	"projectName": "Example", # If you want to chance name
	"attribute2": "Value2",
}

RESPONSE = 201 Created or 200 OK
~~~

title: PATCH
collapse: true

Modify item at {projectId} with body data (partial update instead of full replace as with PUT)
~~~py
URL = "https://###/api/projects/{projectId}?keys={params}"
BODY = {
	"projectName": "Example", # If you want to chance name
	"attribute2": "Value2",
}

RESPONSE = 201 Created or 200 OK??
~~~

title: GET
collapse: true

Get item at {projectId}
~~~py
URL = "https://###/api/projects/{projectId}?keys={params}"
BODY = None

RESPONSE = 200 OK
~~~

OR

Get all projects
~~~py
URL = "https://###/api/projects?keys={params}"
BODY = None

RESPONSE = 200 OK
~~~
title: DELETE
collapse: true

Delete item at {projectId}
~~~py
URL = "https://###/api/projects/{projectId}?keys={params}"
BODY = None

RESPONSE = 200 OK

~~~
1

Repeats of the request will have the same outcome until the state of the resource changes

Tags

#serverless #technical