タスクを作成

post
https://api.box.com/2.0
/tasks

ファイルに対する1個のタスクを作成します。このタスクはいずれのユーザーにも割り当てられていないため、個別に割り当てる必要があります。

リクエスト

bearer [ACCESS_TOKEN]
application/json

リクエスト本文

string本文内省略可能
"review""review"

タスク担当者が実行を求められるアクション。次のいずれかを指定する必要があります。

  • review - 承認または拒否できる承認タスクを定義します
  • complete - 完了できる一般タスクを定義します

次の値のいずれか1つ: review,complete

string本文内省略可能
"all_assignees""all_assignees"

タスクが完了と見なされる前にそのタスクを完了する必要がある担当者を定義します。

  • all_assignees (デフォルト) - タスクが完了と見なされるには、すべての担当者がそのタスクをレビューまたは承認する必要があります。
  • any_assignee - いずれか1人の担当者がタスクをレビューまたは承認すれば、タスクが完了と見なされます。

次の値のいずれか1つ: all_assignees,any_assignee

string / date-time本文内省略可能
"2012-12-12T10:53:43-08:00"

タスクの期限を定義します。指定しない場合は、デフォルトでnullに設定されます。

object本文内

タスクを添付するファイル。

string本文内必須
"11446498"

ファイルのID

string本文内必須
"file"

file

次の値に固定: file

string本文内省略可能
"Please review"""

タスクに含めるメッセージ (省略可)。

レスポンス

application/jsonTask

新しく作成されたタスクを返します。

リクエストのパラメータまたは本文が無効な場合に返されます。

  • bad_request - 本文に有効なリクエストが含まれていない場合に返されます。これは、actionまたはcompletion_ruleが許可された値のいずれでもないことが原因である可能性があります。

ファイルに対するタスクを作成する権限がユーザーにない場合は、エラーを返します。

ファイルが見つからない場合、またはユーザーがファイルにアクセスできない場合はエラーを返します。

予期しないクライアントエラー。

post
タスクを作成
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -X POST "https://api.box.com/2.0/tasks" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "item": {
         "id": "11446498",
         "type": "file"
       },
       "action": "review"
     }'
.NET
var taskParams = new BoxTaskCreateRequest()
{
    Item = new BoxRequestEntity()
    {
        Type = BoxType.file,
        Id = "11111"
    },
    Message = "Please review!"
};
BoxTask task = await client.TasksManager.CreateTaskAsync(taskParams);
Java
BoxFile file = new BoxFile(api, "id");
Date dueAt = new Date();
file.addTask(BoxTask.Action.REVIEW, "Please review this file.", dueAt);
Python
message = 'Please review this'
due_at = "2014-04-03T11:09:43-07:00"
task = client.file(file_id='11111').create_task(message, due_at)
print(f'Task message is {task.message} and it is due at {task.due_at}')
Node
var options = {
	message: 'Please review for publication!',
	due_at: '2014-04-03T11:09:43-07:00'
};
client.tasks.create('22222', options)
	.then(task => {
		/* task -> {
			type: 'task',
			id: '11111',
			item: 
			{ type: 'file',
				id: '22222',
				sequence_id: '0',
				etag: '0',
				sha1: '0bbd79a105c504f99573e3799756debba4c760cd',
				name: 'box-logo.png' },
			due_at: '2014-04-03T11:09:43-07:00',
			action: 'review',
			message: 'Please review for publication!',
			task_assignment_collection: { total_count: 0, entries: [] },
			is_completed: false,
			created_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			created_at: '2013-04-03T11:12:54-07:00' }
		*/
	});

レスポンスの例

{
  "id": "11446498",
  "type": "task",
  "action": "review",
  "completion_rule": "all_assignees",
  "created_at": "2012-12-12T10:53:43-08:00",
  "created_by": {
    "id": "11446498",
    "type": "user",
    "login": "ceo@example.com",
    "name": "Aaron Levie"
  },
  "due_at": "2012-12-12T10:53:43-08:00",
  "is_completed": true,
  "item": {
    "id": "12345",
    "type": "file",
    "etag": "1",
    "file_version": {
      "id": "12345",
      "type": "file_version",
      "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc"
    },
    "name": "Contract.pdf",
    "sequence_id": "3",
    "sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37"
  },
  "message": "Legal review",
  "task_assignment_collection": {
    "entries": [
      {
        "id": "11446498",
        "type": "task_assignment",
        "item": {
          "id": "12345",
          "etag": "1",
          "type": "file",
          "sequence_id": "3",
          "name": "Contract.pdf",
          "sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37",
          "file_version": {
            "id": "12345",
            "type": "file_version",
            "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc"
          }
        },
        "assigned_to": {
          "id": "11446498",
          "type": "user",
          "name": "Aaron Levie",
          "login": "ceo@example.com"
        },
        "message": "Please review",
        "completed_at": "2012-12-12T10:53:43-08:00",
        "assigned_at": "2012-12-12T10:53:43-08:00",
        "reminded_at": "2012-12-12T10:53:43-08:00",
        "resolution_state": "incomplete",
        "assigned_by": {
          "id": "11446498",
          "type": "user",
          "name": "Aaron Levie",
          "login": "ceo@example.com"
        }
      }
    ],
    "total_count": 100
  }
}