ユーザーへのタスクの割り当て
ユーザーへのタスクの割り当て
ユーザーにタスクを割り当てるには、POST /task_assignments
APIにタスクのid
とユーザーの詳細を指定する必要があります。ユーザーについては、アプリケーションはユーザーid
またはユーザーのログインメールを使用できます。これはBoxではユーザーのlogin
と呼ばれます。
cURL
curl -i -X POST "https://api.box.com/2.0/task_assignments" \
-H "authorization: Bearer <ACCESS_TOKEN>" \
-H "content-type: application/json" \
-d '{
"task": {
"id": "11446498",
"type": "task"
},
"assign_to": {
"id": "4823213"
}
}'
TypeScript Gen
await client.taskAssignments.createTaskAssignment({
task: new CreateTaskAssignmentRequestBodyTaskField({
type: 'task' as CreateTaskAssignmentRequestBodyTaskTypeField,
id: task.id!,
}),
assignTo: {
id: currentUser.id,
} satisfies CreateTaskAssignmentRequestBodyAssignToField,
} satisfies CreateTaskAssignmentRequestBody);
Python Gen
client.task_assignments.create_task_assignment(
CreateTaskAssignmentTask(
type=CreateTaskAssignmentTaskTypeField.TASK.value, id=task.id
),
CreateTaskAssignmentAssignTo(id=current_user.id),
)
.NET Gen
await client.TaskAssignments.CreateTaskAssignmentAsync(requestBody: new CreateTaskAssignmentRequestBody(task: new CreateTaskAssignmentRequestBodyTaskField(type: CreateTaskAssignmentRequestBodyTaskTypeField.Task, id: NullableUtils.Unwrap(task.Id)), assignTo: new CreateTaskAssignmentRequestBodyAssignToField() { Id = currentUser.Id }));
Java
BoxUser user = new BoxUser(api, "user-id")
BoxTask task = new BoxTask(api, "id");
task.addAssignment(user);
Python
user = client.user(user_id='11111')
assignment = client.task(task_id='12345').assign(user)
print(f'Assignment ID is {assignment.id} and is assigned to user {assignment.assigned_to.name}')
.NET
// Assign task 11111 to user 22222
var assignmentParams = new BoxTaskAssignmentRequest()
{
Task = new BoxTaskRequest()
{
Id = "11111"
},
AssignTo = new BoxAssignmentRequest()
{
Id = "22222"
}
};
BoxTaskAssignment assignment = await client.TasksManager.CreateTaskAssignmentAsync(assignmentParams);
Node
// Assign task 11111 to user 22222
var taskID = '11111';
var userID = '22222';
client.tasks.assignByUserID(taskID, userID)
.then(assignment => {
/* assignment -> {
type: 'task_assignment',
id: '12345',
item:
{ type: 'file',
id: '33333',
sequence_id: '0',
etag: '0',
sha1: '7840095ee096ee8297676a138d4e316eabb3ec96',
name: 'script.js' },
assigned_to:
{ type: 'user',
id: '22222',
name: 'Sample Assignee',
login: 'assignee@exmaple.com' },
message: null,
completed_at: null,
assigned_at: '2013-05-10T11:43:41-07:00',
reminded_at: null,
resolution_state: 'incomplete',
assigned_by:
{ type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.com' } }
*/
});