Skip to content

REST Documentation

Dilshan Kathriarachchi edited this page Feb 8, 2016 · 1 revision

Create User

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" }
  • 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." }
  • Notes:

    • id is the unique mongo ObjectID created automatically at _id

List Users

Returns json data about all users.

  • URL

    /users

  • Method:

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response:

    • Code: 200
      Content:
    {
	"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." }

Show User

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" }
  • 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." }
  • Sample Call:

      $.ajax({
        url: "/users/1",
        dataType: "json",
        type : "GET",
        success : function(r) {
          console.log(r);
        }
      });
Clone this wiki locally