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

Update a User

Let’s go another time to the creation process:


curl -i -H "Content-type: application/json" -X POST -d '{"first_name":"Steve", "last_
˓→name": "Roger"}'
http://localhost:5000/users/
HTTP/1.0 201 CREATED
Location: http://localhost:5000/users/3/ Content-Type: application/json
Content-Length: 0
Server: Werkzeug/0.8.3 Python/2.7.2 Date: Mon, 14 Oct 2013 20:45:38 GMT
But well everybody now that Steve Roger real name is Captain America. Let’s update this user:
curl -i -H "Content-type: application/json" -X PUT -d '{"first_name":"Capitain",
˓→"last_name": "America"}'
http://localhost:5000/users/3/
HTTP/1.0 200 OK
Content-Type: application/json Content-Length: 58
Server: Werkzeug/0.8.3 Python/2.7.2 Date: Mon, 14 Oct 2013 20:57:47 GMT
{"first_name": "Capitain", "last_name": "America", "id": 3, "ressource_uri": "/users/
˓→3/"}

Argh! Thats a typo. the fist name is “Captain”, not “Capitain”. Let’s correct this:
curl -i -H "Content-type: application/json" -X PUT -d '{"first_name":"Captain"}'
˓→http://localhost:5000/users/3/ HTTP/1.0 200 OK

Content-Type: application/json Content-Length: 59


Server: Werkzeug/0.8.3 Python/2.7.2 Date: Mon, 14 Oct 2013 21:08:04 GMT
{"first_name": "Captain", "last_name": "America", "id": 3, "ressource_uri": "/users/3/
˓→"}

You might also like