Add Assignment to Project With Cost Introduction
This API allows you to add assignments to your project file with specifying its cost and returns assignment item in a response, 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}/assignments
POST
Add a new assignment to a MS Project File
PostAssignment
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("Cost_Res.mpp");
var response = await TasksApi.PostAssignmentAsync(new PostAssignmentRequest
{
ResourceUid = 1,
Cost = 2,
TaskUid = 0,
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual((int)HttpStatusCode.OK, response.Code);
Assert.IsNotNull(response.AssignmentItem);
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 = "AddAssignmentWithCost.mpp";
$folder = $this->uploadFile("Cost_Res.mpp", $remoteName, '');
$request = new Requests\PostAssignmentRequest($remoteName, 0, 1, null, 2, null, self::$storageName, $folder);
$result = $this->tasks->postAssignment($request);
Assert::assertEquals(200, $result->getCode());
Assert::assertNotNull($result->getAssignmentItem());
$assignmentUid = $result->getAssignmentItem()->getUid();
$getResponse = $this->tasks->getAssignment(new Requests\GetAssignmentRequest($remoteName, $assignmentUid, self::$storageName, $folder));
Assert::assertEquals(200, $getResponse->getCode());
Assert::assertNotNull($getResponse->getAssignment());
Assert::assertEquals(0, $getResponse->getAssignment()->getTaskUid());
Assert::assertEquals(2, $getResponse->getAssignment()->getCost());
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 = 'Cost_Res.mpp'
self.upload_file(filename)
request = PostAssignmentRequest(filename, 0, 1, None, 2)
result = self.tasks_api.post_assignment(request)
self.assertIsNotNone(result)
self.assertIsInstance(result, AssignmentItemResponse)
self.assertIsNotNone(result.assignment_item)
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 = "Cost_Res.mpp";
const localPath = "./Data/" + fileName;
const remotePath = "Temp/Data/";
const remoteFullPath = remotePath + "/" + fileName;
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
const request = new PostAssignmentRequest();
request.resourceUid = 1;
request.cost = 2;
request.taskUid = 0;
request.name = fileName;
request.folder = remotePath;
const result = await tasksApi.postAssignment(request);
expect(result.response.statusCode).to.equal(200);
expect(result.body.assignmentItem).not.undefined.and.not.null;
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)
postAssignmentOpts := &requests.PostAssignmentOpts{
ResourceUid: 1,
Cost: optional.NewFloat32(2),
TaskUid: 0,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.PostAssignment(ctx, postAssignmentOpts)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.AssignmentItem)
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 = "Cost_Res.mpp";
String remoteFileName = TestInitializer.UploadFile(localFileName);
PostAssignmentRequest request1 = new PostAssignmentRequest(remoteFileName, 0, 1, null, BigDecimal.valueOf(2), null, null, null);
AssignmentItemResponse result1 = TestInitializer.tasksApi.postAssignment(request1);
assertNotNull(result1);
assertEquals(200, (int) result1.getCode());
assertNotNull(result1.getAssignmentItem());