Move a Task to Sibling Task Introduction
This example explains how to move a task to another position under the same parent and the same outline level, using Aspose.Tasks Cloud. Aspose.Tasks Cloud is a REST API which can be used with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
API
Type
Description
Resource Link
/tasks/{name}/tasks/{taskUid}/moveToSibling
PUT
Move a task to another position under the same parent and the same outline level
PutMoveTaskToSibling
cURL Example
SDKs
The Aspose.Tasks Cloud SDKs can be downloaded from the following page: Available SDKs
SDK Examples
C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var remoteName = await UploadFileToStorageAsync("NewProductDev.mpp");
var response = await TasksApi.PutMoveTaskToSiblingAsync(new PutMoveTaskToSiblingRequest
{
Name = remoteName,
Folder = this.DataFolder,
TaskUid = 41,
BeforeTaskUid = 40
});
Assert.AreEqual((int)HttpStatusCode.OK, response.Code);
PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-php/
$remoteName = "MoveTaskToSibling.mpp";
$folder = $this->uploadFile("NewProductDev.mpp", $remoteName, '');
$response = $this->tasks->putMoveTaskToSibling(new Requests\PutMoveTaskToSiblingRequest($remoteName, 41, 40, null, self::$storageName, $folder));
Assert::assertEquals(200, $response->getCode());
$response = $this->tasks->getTask(new Requests\GetTaskRequest($remoteName, 38, self::$storageName, $folder));
Assert::assertEquals(200, $response->getCode());
Assert::assertNotNull($response->getTask());
Assert::assertNotNull($response->getTask()->getSubtasksUids());
Assert::isTrue(array(39, 41, 40) === $response->getTask()->getSubtasksUids());
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-python
filename = 'NewProductDev.mpp'
self.upload_file(filename)
put_request = PutMoveTaskToSiblingRequest(filename, 40, 41)
put_result = self.tasks_api.put_move_task_to_sibling(put_request)
self.assertIsNotNone(put_result)
self.assertIsInstance(put_result, AsposeResponse)
get_request = GetTaskRequest(filename, 38)
get_result = self.tasks_api.get_task(get_request)
self.assertIsNotNone(get_result)
self.assertIsInstance(get_result, TaskResponse)
self.assertEqual([39, 40, 41], get_result.task.subtasks_uids)
Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-node
const fileName = "NewProductDev.mpp";
const localPath = "./Data/" + fileName;
const remotePath = "Temp/Data";
const remoteFullPath = remotePath + "/" + fileName;
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
const putMoveToSiblingRequest = new PutMoveTaskToSiblingRequest();
putMoveToSiblingRequest.name = fileName;
putMoveToSiblingRequest.folder = remotePath;
putMoveToSiblingRequest.beforeTaskUid = 41;
putMoveToSiblingRequest.taskUid = 40;
const putMoveToSiblingResult = await tasksApi.putMoveTaskToSibling(putMoveToSiblingRequest);
expect(putMoveToSiblingResult.body.code).to.equal(200);
Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
putMoveToSiblingOpts := &requests.PutMoveTaskToSiblingOpts{
TaskUid: 40,
BeforeTaskUid: 41,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putMoveToSiblingResult, _, err := client.TasksApi.PutMoveTaskToSibling(ctx, putMoveToSiblingOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putMoveToSiblingResult.Code)
Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-java/
String localFileName = "NewProductDev.mpp";
String remoteFileName = TestInitializer.UploadFile(localFileName);
PutMoveTaskToSiblingRequest request1 = new PutMoveTaskToSiblingRequest(remoteFileName, 40, 41, null, null, null);
AsposeResponse result1 = TestInitializer.tasksApi.putMoveTaskToSibling(request1);
assertNotNull(result1);
assertEquals(Integer.valueOf(200), result1.getCode());