Skip to content

0.7 List Semantics

Kurtis Nusbaum edited this page Apr 23, 2013 · 1 revision

The UDJ-Server has common semantics for interacting with lists.

Getting the list

GET /endpoint

Returns the entire list as a JSON array.

Example for a list of IDs:

GET /endpoint
[id1, id2, id3, ... idN]

Example for a list of User objects:

GET /endpoint
[{
  "id" : "12345",
  "username" : "testuser",
  "first_name" : "Test ",
  "last_name" : "User"
},
{
  "id" : "54321",
  "username" : "anotheruser",
  "first_name" : "Another ",
  "last_name" : "User"
}]

Adding an element to the list

If the element you're adding is already in the list, an error will be returned.

PUT /endpoint

For objects that have an id, just send the id to /endpoint/id instead of sending the whole object (see PUT /endpoint/id below).

For structures that will have an id after this call, but don't yet, send the whole object to /endpoint and the id field will be ignored.

Example: Creating a new user:

PUT to /endpoint
{  
  // No id field, since non-existant users don't have an id yet.
  // If an id field was included, it would be ignore.
  "username" : "testuser",
  "first_name" : "Test ",
  "last_name" : "User"
}

PUT /endpoint/id

Adds and element to a list by it's id.

Example: Adding a user (id 1756) to a list:

PUT /endpoint/1756

Removing an element from the list

DELETE /endpoint/id

Removes the specified element from the list.

Modifying the list (multiple operations)

POST /endpoint

Takes two parameters, add and delete. Each contains a list of elements to add or delete.

At least one of the parameters must be specified, or an error is returned.

Clone this wiki locally