Update an Entity

The following is the standard procedure for retrieving a single entity from the Registration database and updating that entity’s data. The API is used to fetch JSON, which is then modified, and updated using another API call.

For updating records, either entity.update, or entity.replace are used.

Adding Data to a Single Entity

  1. Retrieve a single entity using entity.
  2. Edit json file to remove Reserved Attributes. These are used by Registration, and cannot be changed:
    uuid
    lastUpdated
    created
    all of the id attributes in any plural (unless you are using entity.update to replace a plural).
  3. Update user data in edited JSON file.
  4. Use entity.update to pass modified JSON file back, appending new information.

Replacing User Data

The following is an example of a JSON file with reserved attributes removed.

{
  "aboutMe":"Foo.",
  "birthday":"1986-07-10",
  "currentLocation":"",
  "display":{
    "aboutMe":"true",
    "birthday":"false",
    "currentLocation":"false",
    "displayName":"true",
    "email":"false",
    "gender":"true",
    "givenName":"false",
    "photo":"false",
    "primaryAddress":{
      "address1":"false",
      "phone":"false"
    }
  }
}

Replacing a Plural with entity.update

In this example, plurals with IDs are left in the JSON file, and will replace existing data for those IDs:

{
  "profiles": [
    {
      "accessCredentials": {
        "accessToken": null,
        "expires": 1365933461,
        "scopes": "user_likes,user_about_me,user_activities,read_stream,user_relationships",
        "type": "Facebook",
        "uid": "123456789123456"
      },
      "domain": "facebook.com",
      "friends": [],
      "id": 123456,
      "identifier": "http://www.facebook.com/profile.php?id=123456789123456",
      "profile": {
        "aboutMe": "This is about me.",
        "accounts": [],
        "activities": [],
        "addresses": [
          {
            "country": null,
            "extendedAddress": null,
            "formatted": null,
            "id": 155225,
            "latitude": null,
            "locality": null,
            "longitude": null,
            "poBox": null,
            "postalCode": null,
            "primary": null,
            "region": null,
            "streetAddress": null,
            "type": "currentLocation"
          },
          {
            "country": null,
            "extendedAddress": null,
            "formatted": null,
            "id": 123456,
            "latitude": null,
            "locality": null,
            "longitude": null,
            "poBox": null,
            "postalCode": null,
            "primary": null,
            "region": null,
            "streetAddress": null,
            "type": "hometown"
          }
        ],
      "anniversary": null,
      "birthday": "1986-07-10",
      "bodyType": {
        "build": null,
        "color": null,
        "eyeColor": null,
        "hairColor": null,
        "height": null
      },
      "books": [
        {
          "book": "1984",
          "id": 654321
        },
        {
          "book": "A Tale of Two Cities",
          "id": 456789
        }
      ],
      "provider": null,
      "remote_key": ""
    }
  ]
}