-
Notifications
You must be signed in to change notification settings - Fork 0
REST Documentation
Dilshan Kathriarachchi edited this page Feb 8, 2016
·
1 revision
Creates a new user.
-
URL
/users
-
Method:
POST
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success Response:
-
Code: 201
Content:{ id : "507f1f77bcf86cd799439011", name : "Michael Bloom" }
-
Code: 201
-
Error Response:
-
Code: 503 SERVICE UNAVAILABLE
Content:{ error : "User cannot be created at the moment." }
OR
-
Code: 403 FORBIDDEN
Content:{ error : "You are unauthorized to make this request." }
-
Code: 503 SERVICE UNAVAILABLE
-
Notes:
-
id
is the unique mongo ObjectID created automatically at_id
-
Returns json data about all users.
-
URL
/users
-
Method:
GET
-
URL Params
None
-
Data Params
None
-
Success Response:
-
Code: 200
Content:
-
Code: 200
{
"users": [{
"id": "507f1f77bcf86cd799439011",
"name": "Michael Bloom"
}, {
"id": "859f1f77fdd55aa193438585",
"name": "John Doe"
}]
}
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "User doesn't exist" }
OR
-
Code: 401 UNAUTHORIZED
Content:{ error : "You are unauthorized to make this request." }
-
Code: 404 NOT FOUND
Returns json data about a single user.
-
URL
/users/:id
-
Method:
GET
-
URL Params
Required:
id=[string (ObjectID)]
-
Data Params
None
-
Success Response:
-
Code: 200
Content:{ id : "507f1f77bcf86cd799439011", name : "Michael Bloom" }
-
Code: 200
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "User doesn't exist" }
OR
-
Code: 401 UNAUTHORIZED
Content:{ error : "You are unauthorized to make this request." }
-
Code: 404 NOT FOUND
-
Sample Call:
$.ajax({ url: "/users/1", dataType: "json", type : "GET", success : function(r) { console.log(r); } });