Update a Task Link Introduction
This example allows you to update a task link in a Project using Aspose.Tasks Cloud API in your applications. You can use our REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
API
Type
Description
Resource Link
/tasks/{name}/taskLinks
PUT
Update a existing task link
PutTaskLink
cURL Example
Request
Copy
curl - X PUT "https://api.aspose.cloud/v3.0/tasks/NewProductDev.mpp/taskLinks/0" - H "accept: application/json" - H "Content-Type: application/json" - H "x-aspose-client: Containerize.Swagger" - d "{ \"link\": { \"href\": \"string\", \"rel\": \"string\", \"type\": \"string\", \"title\": \"string\" }, \"index\": 1, \"predecessorUid\": 0, \"successorUid\": 0, \"linkType\": \"FinishToFinish\", \"lag\": 0, \"lagFormat\": \"Minute\"}"
Response
Copy
{
"code" : 0 ,
"status" : "string" ,
"taskLink" : {
"link" : {
"href" : "string" ,
"rel" : "string" ,
"type" : "string" ,
"title" : "string"
},
"index" : 0 ,
"predecessorUid" : 0 ,
"successorUid" : 0 ,
"linkType" : "FinishToFinish" ,
"lag" : 0 ,
"lagFormat" : "Minute"
}
}
SDKs
The Aspose.Tasks Cloud SDKs can be downloaded from the following page: Available SDKs
SDK Examples
C#
This file contains hidden or 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 linksResponse = await TasksApi.GetTaskLinksAsync(new GetTaskLinksRequest()
{
Name = remoteName,
Folder = this.DataFolder
});
var taskLinkToEdit = linksResponse.TaskLinks[0];
// Modification of PredecessorUid and SuccessorUid fields is not supported.
taskLinkToEdit.LinkType = TaskLinkType.StartToFinish;
taskLinkToEdit.Lag = 9600;
taskLinkToEdit.LagFormat = TimeUnitType.Day;
var response = await TasksApi.PutTaskLinkAsync(new PutTaskLinkRequest()
{
Index = 1,
TaskLink = taskLinkToEdit,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual((int)HttpStatusCode.OK, response.Code);
PHP
This file contains hidden or 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 = "EditTaskLink.mpp";
$folder = $this->uploadFile("NewProductDev.mpp", $remoteName, '');
$response = $this->tasks->getTaskLinks(new Requests\GetTaskLinksRequest($remoteName, self::$storageName, $folder, null));
Assert::assertEquals(200, $response->getCode());
Assert::assertNotNull($response->getTaskLinks());
$taskLinkToEdit = $response->getTaskLinks()[0];
// Modification of PredecessorUid and SuccessorUid fields is not supported.
$taskLinkToEdit->setLinkType(Model\TaskLinkType::START_TO_FINISH);
$taskLinkToEdit->setLag(9600);
$taskLinkToEdit->setLagFormat(Model\TimeUnitType::DAY);
$response = $this->tasks->putTaskLink(new Requests\PutTaskLinkRequest($remoteName, 1, $taskLinkToEdit, self::$storageName, $folder, null));
Assert::assertEquals(200, $response->getCode());
$response = $this->tasks->getTaskLinks(new Requests\GetTaskLinksRequest($remoteName, self::$storageName, $folder, null));
Assert::assertEquals(200, $response->getCode());
Assert::assertNotNull($response->getTaskLinks());
Assert::assertEquals(Model\TaskLinkType::START_TO_FINISH, $response->getTaskLinks()[0]->getLinkType());
Assert::assertEquals(9600, $response->getTaskLinks()[0]->getLag());
Assert::assertEquals(Model\TimeUnitType::DAY, $response->getTaskLinks()[0]->getLagFormat());
Python
This file contains hidden or 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)
get_request = GetTaskLinksRequest(filename)
get_result = self.tasks_api.get_task_links(get_request)
task_link_to_edit = get_result.task_links[0]
# Modification of PredecessorUid and SuccessorUid fields is not supported.
task_link_to_edit.link_type = TaskLinkType.STARTTOFINISH
task_link_to_edit.lag = 9600
task_link_to_edit.lag_format = TimeUnitType.DAY
put_request = PutTaskLinkRequest(filename, 1, task_link_to_edit)
put_result = self.tasks_api.put_task_link(put_request)
self.assertIsNotNone(put_result)
self.assertIsInstance(put_result, TaskLinkResponse)
get_result = self.tasks_api.get_task_links(get_request)
self.assertIsNotNone(get_result.task_links)
self.assertEqual(TaskLinkType.STARTTOFINISH, get_result.task_links[0].link_type)
self.assertEqual(9600, get_result.task_links[0].lag)
self.assertEqual(TimeUnitType.DAY, get_result.task_links[0].lag_format)
Node.js
This file contains hidden or 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 getRequest = new GetTaskLinksRequest();
getRequest.name = fileName;
getRequest.folder = remotePath;
let getResult = await tasksApi.getTaskLinks(getRequest);
const taskLinkToEdit = getResult.body.taskLinks[0];
// Modification of PredecessorUid and SuccessorUid fields is not supported.
taskLinkToEdit.linkType = TaskLinkType.StartToFinish;
taskLinkToEdit.lag = 9600;
taskLinkToEdit.lagFormat = TimeUnitType.Day;
const putRequest = new PutTaskLinkRequest();
putRequest.name = fileName;
putRequest.folder = remotePath;
putRequest.index = 1;
putRequest.taskLink = taskLinkToEdit;
const putResult = await tasksApi.putTaskLink(putRequest);
expect(putResult.response.statusCode).to.equal(200);
Go
This file contains hidden or 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)
getResult, _, err := client.TasksApi.GetTaskLinks(ctx, &requests.GetTaskLinksOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), getResult.Code)
assert.Equal(t, 24, len(getResult.TaskLinks))
taskLinkToEdit := &getResult.TaskLinks[0]
newTaskLinkType := models.START_TO_FINISH_TaskLinkType
newTimeUnitType := models.DAY_TimeUnitType
// Modification of PredecessorUid and SuccessorUid fields is not supported.
taskLinkToEdit.Lag = 9600
taskLinkToEdit.LagFormat = &newTimeUnitType
taskLinkToEdit.LinkType = &newTaskLinkType
putOpts := &requests.PutTaskLinkOpts{
Index: 1,
TaskLink: *taskLinkToEdit,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
putResult, _, err := client.TasksApi.PutTaskLink(ctx, putOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResult.Code)
Java
This file contains hidden or 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);
GetTaskLinksRequest request1 = new GetTaskLinksRequest(remoteFileName, null, null);
TaskLinksResponse result1 = TestInitializer.tasksApi.getTaskLinks(request1);
assertNotNull(result1);
assertEquals(Integer.valueOf(200), result1.getCode());
assertNotNull(result1.getTaskLinks());
TaskLink taskLinkToEdit = result1.getTaskLinks().get(0);
// Modification of PredecessorUid and SuccessorUid fields is not supported.
taskLinkToEdit.setLinkType(TaskLinkType.STARTTOFINISH);
taskLinkToEdit.setLag(9600);
taskLinkToEdit.setLagFormat(TimeUnitType.DAY);
PutTaskLinkRequest request2 = new PutTaskLinkRequest(remoteFileName, 1, taskLinkToEdit, null, null, null);
TaskLinkResponse result2 = TestInitializer.tasksApi.putTaskLink(request2);
assertNotNull(result2);
assertEquals(Integer.valueOf(200), result2.getCode());