Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Delete a user

Let’s add a new user:


curl -i -H "Content-type: application/json" -X POST -d '{"first_name":"Peter", "last_
˓→name": "Something"}' http://localhost:5000/users/

HTTP/1.0 201 CREATED


Location: http://localhost:5000/users/2/ Content-Type: application/json
Content-Length: 0
Server: Werkzeug/0.8.3 Python/2.7.2 Date: Mon, 14 Oct 2013 13:00:13 GMT
and now delete it:
curl -i -X DELETE "http://localhost:5000/users/2/"
HTTP/1.0 200 OK
Content-Type: application/json Content-Length: 0
Server: Werkzeug/0.8.3 Python/2.7.2 Date: Mon, 14 Oct 2013 20:41:46 GMT
You can check that the user no longer exists:
curl -i "http://localhost:5000/users/2/" HTTP/1.0 404 NOT FOUND
Content-Type: application/json Connection: close
Server: Werkzeug/0.8.3 Python/2.7.2 Date: Tue, 15 Oct 2013 11:16:33 GMT
{ "error": "<p>The requested URL was not found on the
server.</p><p>If you entered the URL manually please check your
spelling and try again.</p>" }
And the list is also updated:
curl -i "http://localhost:5000/users/" HTTP/1.0 200 OK
Content-Type: application/json Content-Length: 125
Server: Werkzeug/0.8.3 Python/2.7.2 Date: Tue, 15 Oct 2013 11:17:46 GMT
{ "meta": {
"filters": {}
}, "object_list": [
{
"first_name": "John",
"id": 1,
"last_name": "Doe", "ressource_uri": "/users/1/"
}
]

You might also like