Modifying Custom Fields

Custom fields can be modified easily, as shown in the following example:

curl -v -X POST \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  -H "Content-Type: application/vnd.kii.UserUpdateRequest+json" \
  "https://api.kii.com/api/apps/{APP_ID}/users/me" \
  -d '{"friends": 401, "age": 28}'

Note that the REST API works differently on predefined fields and custom fields. If an existing predefined field is not explicitly specified for the update operation, the field remains unchanged on Kii Cloud. On the other hand, if an existing custom field is not explicitly specified for the update operation, the field is deleted.

  • If the specified custom field is new, it will be added as a new user attribute
  • If the specified custom field already exists, its value will be replaced with the new one
  • If the existing custom field is not specified, it will be removed from the user attributes

In the above sample, for example, "followers" and "status" will be removed, "friends" will be updated, and "age" will be created in the user profile.

Kii Cloud will respond with the modification time in UNIX time (msec) in UTC like the following:

< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Access-Control-Allow-Origin: *
< Content-Type: application/vnd.kii.UserDataRetrievalResponse+json
< Content-Length: 34
< Date: Tue, 26 Jun 2012 15:43:05 GMT
<
{
  "modifiedAt" : 1340725385432
}

Only users themselves can update their fields. See User Attributes to learn more on who can access the user's fields.

If you modify an email address or phone number while their verification is enabled, the corresponding verification flow will be launched. You can log in with the new email address and phone number after the verification is done. See Verifying the User's Email Address and Verifying the User's Phone Number for more details.