Add a Task Link to Project Introduction
This example allows you to add a task link to 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
POST
Add a new task link
PostTaskLink
cURL Example
Request
Copy
curl - X POST "https://api.aspose.cloud/v3.0/tasks/sample-project.mpp/taskLinks" - 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\": 2, \"predecessorUid\": 1, \"successorUid\": 2, \"linkType\": \"FinishToFinish\", \"lag\": 0, \"lagFormat\": \"Minute\"}"
Response
Copy
{
"Code" : "200" ,
"Status" : "OK"
}
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.PostTaskLinkAsync(new PostTaskLinkRequest()
{
TaskLink = new TaskLink
{
PredecessorUid = 28,
SuccessorUid = 30,
LinkType = TaskLinkType.StartToStart,
Lag = 9600,
LagFormat = TimeUnitType.Day
},
Name = remoteName,
Folder = this.DataFolder
});
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 = "AddTaskLink.mpp";
$folder = $this->uploadFile("NewProductDev.mpp", $remoteName, '');
$taskLink = new TaskLink();
$taskLink->setPredecessorUid(28);
$taskLink->setSuccessorUid(30);
$taskLink->setLinkType(Model\TaskLinkType::START_TO_START);
$taskLink->setLag(9600);
$taskLink->setLagFormat(Model\TimeUnitType::DAY);
$response = $this->tasks->postTaskLink(new Requests\PostTaskLinkRequest($remoteName, $taskLink, self::$storageName, $folder, null));
Assert::assertEquals(200, $response->getCode());
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)
task_link = TaskLink(predecessor_uid=28, successor_uid=30, link_type=TaskLinkType.STARTTOSTART, lag=9600)
task_link.lag_format = TimeUnitType.DAY
post_request = PostTaskLinkRequest(filename, task_link)
post_result = self.tasks_api.post_task_link(post_request)
self.assertIsNotNone(post_result)
self.assertIsInstance(post_result, AsposeResponse)
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 taskLink = new TaskLink()
taskLink.predecessorUid = 28;
taskLink.successorUid = 30;
taskLink.linkType = TaskLinkType.StartToStart;
taskLink.lag = 9600;
taskLink.lagFormat = TimeUnitType.Day;
const request = new PostTaskLinkRequest();
request.name = fileName;
request.folder = remotePath;
request.taskLink = taskLink;
const result = await tasksApi.postTaskLink(request);
expect(result.response.statusCode).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)
newTaskLinkType := models.START_TO_START_TaskLinkType
newTimeUnitType := models.DAY_TimeUnitType
taskLink := models.TaskLink{
PredecessorUid: 28,
SuccessorUid: 30,
Lag: 9600,
LagFormat: &newTimeUnitType,
LinkType: &newTaskLinkType,
}
postOpts := &requests.PostTaskLinkOpts{
TaskLink: taskLink,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
postResult, _, err := client.TasksApi.PostTaskLink(ctx, postOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), postResult.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);
TaskLink taskLink = new TaskLink();
taskLink.setPredecessorUid(28);
taskLink.setSuccessorUid(30);
taskLink.setLinkType(TaskLinkType.STARTTOSTART);
taskLink.setLag(9600);
taskLink.setLagFormat(TimeUnitType.DAY);
PostTaskLinkRequest request1 = new PostTaskLinkRequest(remoteFileName, taskLink, null, null, null);
AsposeResponse result1 = TestInitializer.tasksApi.postTaskLink(request1);
assertNotNull(result1);
assertEquals(Integer.valueOf(200), result1.getCode());