7.3. Creating Resources

There are two ways to create resources.

  • To create a resource using an ID that you specify, perform an HTTP PUT request with headers Content-Type: application/json and If-None-Match: *, and the JSON content of your resource.

    The following example creates a new user entry with ID newuser.

    $ curl
     --request PUT
     --user kvaughan:bribery
     --header "Content-Type: application/json"
     --header "If-None-Match: *"
     --data '{
      "_id": "newuser",
      "contactInformation": {
        "telephoneNumber": "+1 408 555 1212",
        "emailAddress": "newuser@example.com"
      },
      "name": {
        "familyName": "New",
        "givenName": "User"
      },
      "displayName": "New User",
      "manager": [
        {
          "_id": "kvaughan",
          "displayName": "Kirsten Vaughan"
        }
      ]
     }'
     http://opendj.example.com:8080/users/newuser?_prettyPrint=true
    {
      "_rev" : "000000005b337348",
      "schemas" : [ "urn:scim:schemas:core:1.0" ],
      "contactInformation" : {
        "telephoneNumber" : "+1 408 555 1212",
        "emailAddress" : "newuser@example.com"
      },
      "_id" : "newuser",
      "name" : {
        "familyName" : "New",
        "givenName" : "User"
      },
      "userName" : "newuser@example.com",
      "displayName" : "New User",
      "meta" : {
        "created" : "2013-04-11T09:58:27Z"
      },
      "manager" : [ {
        "_id" : "kvaughan",
        "displayName" : "Kirsten Vaughan"
      } ]
    }
  • To create a resource letting the server choose the ID, perform an HTTP POST with _action=create as described in Section 7.8, “Using Actions”.