GET all users
curl -i -X GET http://childrewards.herokuapp.com/users
GET second user
curl -i -X GET http://childrewards.herokuapp.com/users/518e921e90c0800200000002
DELETE second user
curl -i -X DELETE http://childrewards.herokuapp.com/users/518e921e90c0800200000002
Add another user
curl -i -X POST -H 'Content-Type:application/json' -d '{"first":"Azan", "last":"Sarosh", "year":"2001", "country":"USA","region":"Pacific Northwest", "city":"Renton"}' http://childrewards.herokuapp.com/users
GET all users - again
curl -i -X GET http://childrewards.herokuapp.com/users
Update a user
curl -i -X PUT -H 'Content-Type:application/json' -d '{"name":"Rafat", "year":"1970"}' http://childrewards.herokuapp.com/users/change-this-id
GET all users to cross check
curl -i -X GET http://childrewards.herokuapp.com/users
Get all users
➜ ~ curl -i -X GET http://localhost:3000/users
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 386
Date: Sat, 11 May 2013 03:21:33 GMT
Connection: keep-alive
[
{
"first": "Nilesh",
"last": "Londhe",
"year": "1966",
"country": "USA",
"region": "Pacific Northwest",
"city": "Sammamish",
"_id": "518db920e97695af40000001"
},
{
"first": "Rafat",
"last": "Sarosh",
"year": "1970",
"country": "USA",
"region": "Pacific Northwest",
"city": "Renton",
"_id": "518db920e97695af40000002"
}
]
Get a user with _id value of 518db920e97695af40000002
➜ ~ curl -i -X GET http://localhost:3000/users/518db920e97695af40000002
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 170
Date: Sat, 11 May 2013 03:22:20 GMT
Connection: keep-alive
{
"first": "Rafat",
"last": "Sarosh",
"year": "1970",
"country": "USA",
"region": "Pacific Northwest",
"city": "Renton",
"_id": "518db920e97695af40000002"
}
Delete a user with _id value of 518db920e97695af40000002
➜ ~ curl -i -X DELETE http://localhost:3000/users/518db920e97695af40000002
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 2
Date: Sat, 11 May 2013 03:23:05 GMT
Connection: keep-alive
{}
List all users again and notice second user is deleted
➜ ~ curl -i -X GET http://localhost:3000/users
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 196
Date: Sat, 11 May 2013 03:23:17 GMT
Connection: keep-alive
[
{
"first": "Nilesh",
"last": "Londhe",
"year": "1966",
"country": "USA",
"region": "Pacific Northwest",
"city": "Sammamish",
"_id": "518db920e97695af40000001"
}
]
Add a new user
➜ ~ curl -i -X POST -H 'Content-Type:application/json' -d '{"first":"Rafat Cool Guy", "last":"Sarosh", "year":"1972", "country":"USA","region":"Pacific Northwest", "city":"Renton"}' http://localhost:3000/users
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 179
Date: Sat, 11 May 2013 03:26:12 GMT
Connection: keep-alive
{
"first": "Rafat Cool Guy",
"last": "Sarosh",
"year": "1972",
"country": "USA",
"region": "Pacific Northwest",
"city": "Renton",
"_id": "518dba54e97695af40000003"
}
List all users again and notice a new user is added
➜ ~ curl -i -X GET http://localhost:3000/users
HTTP/1.1 200 OKX-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 395
Date: Sat, 11 May 2013 03:26:18 GMT
Connection: keep-alive
[
{
"first": "Nilesh",
"last": "Londhe",
"year": "1966",
"country": "USA",
"region": "Pacific Northwest",
"city": "Sammamish",
"_id": "518db920e97695af40000001"
},
{
"first": "Rafat Cool Guy",
"last": "Sarosh",
"year": "1972",
"country": "USA",
"region": "Pacific Northwest",
"city": "Renton",
"_id": "518dba54e97695af40000003"
}
]
Modify user with _id value of 518dba54e97695af40000003
➜ ~ curl -i -X PUT -H 'Content-Type:application/json' -d '{"name":"Rafat", "year":"1970"}' http://localhost:3000/users/518dba54e97695af40000003
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 39
Date: Sat, 11 May 2013 03:28:09 GMT
Connection: keep-alive
{
"name": "Rafat",
"year": "1970"
}
List all users to cross check the modification
➜ ~ curl -i -X GET http://localhost:3000/users
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 284
Date: Sat, 11 May 2013 03:28:13 GMT
Connection: keep-alive
[
{
"first": "Nilesh",
"last": "Londhe",
"year": "1966",
"country": "USA",
"region": "Pacific Northwest",
"city": "Sammamish",
"_id": "518db920e97695af40000001"
},
{
"_id": "518dba54e97695af40000003",
"name": "Rafat",
"year": "1970"
}
]