Moving an Object Body

You can move an object body from one KiiObject to another. Moving an object body can be achieved within a scope or across scopes (e.g., moving an object body from a KiiObject in the application scope to a KiiObject in the user scope).

The following conditions must be met in order to move an object body:

  • You have the read and write permissions on both the source and target KiiObjects.
  • The source and target KiiObjects must exist when you move an object body.
  • The source KiiObject must have an object body.

If the target KiiObject has an object body, it will be replaced with the newly moved object body. If you move an object body that has been published, the object body becomes inaccessible.

The target KiiObject is specified with its scope, bucket ID, and the KiiObject ID. The scope is specified in one of the following formats:

  • Application scope:

    "targetObjectScope" : {
      "appID" : "{APP_ID}",
      "type" : "APP"
    }
    
  • Group scope:

    "targetObjectScope" : {
      "appID" : "{APP_ID}",
      "groupID" : "{GROUP_ID}",
      "type" : "APP_AND_GROUP"
    }
    
  • User scope:

    "targetObjectScope" : {
      "appID" : "{APP_ID}",
      "userID" : "{USER_ID}",
      "type" : "APP_AND_USER"
    }
    

Here is an example of moving an object body from a KiiObject in the application scope to a KiiObject in the user scope.

curl -v -X POST \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  -H "Content-Type: application/vnd.kii.ObjectBodyMoveRequest+json" \
  "https://api.kii.com/api/apps/{APP_ID}/buckets/{SOURCE_BUCKET_ID}/objects/{SOURCE_OBJECT_ID}/body/move" \
  -d '{
  "targetObjectScope" : {
    "appID" : "{APP_ID}",
    "userID" : "{USER_ID}",
    "type" : "APP_AND_USER"
  },
  "targetBucketID" : "{TARGET_BUCKET_ID}",
  "targetObjectID" : "{TARGET_OBJECT_ID}"
  }'

If successful, a 204 response is returned.