Delete an Assignment from a Project Introduction
This example allows you to delete a project assignment along with all references to it, 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/{assignmentUid}
DELETE
Deletes a project assignment with all references to it
DeleteAssignment
cURL Example
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 response = await TasksApi.DeleteAssignmentAsync(new DeleteAssignmentRequest
{
AssignmentUid = 63,
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 = "DeleteAssignment.mpp";
$folder = $this->uploadFile("NewProductDev.mpp", $remoteName, '');
$response = $this->tasks->deleteAssignment(new Requests\DeleteAssignmentRequest($remoteName, 63, self::$storageName, $folder));
Assert::assertEquals(200, $response->getCode());
$getResponse = $this->tasks->getAssignments(new Requests\GetAssignmentsRequest($remoteName, self::$storageName, $folder));
Assert::assertEquals(200, $getResponse->getCode());
Assert::assertNotNull($getResponse->getAssignments());
Assert::assertNotNull($getResponse->getAssignments()->getAssignmentItem());
Assert::isTrue(count($getResponse->getAssignments()->getAssignmentItem()) > 0);
foreach ($getResponse->getAssignments()->getAssignmentItem() as $assignment) {
Assert::isFalse($assignment->getTaskUid() == 34 && $assignment->getResourceUid() == 1);
Assert::isFalse($assignment->getUid() == 63);
}
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)
delete_response = self.tasks_api.delete_assignment(DeleteAssignmentRequest(filename, 63))
self.assertIsInstance(delete_response, AsposeResponse)
assignment_items_response = self.tasks_api.get_assignments(GetAssignmentsRequest(filename))
self.assertIsInstance(assignment_items_response, AssignmentItemsResponse)
self.assertIsNotNone(assignment_items_response.assignments)
for assignment in assignment_items_response.assignments.assignment_item:
self.assertFalse(assignment.task_uid == 34 & assignment.resource_uid == 1)
self.assertNotEqual(63, assignment.uid)
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 request = new DeleteAssignmentRequest();
request.assignmentUid = 63;
request.name = fileName;
request.folder = remotePath;
const result = await tasksApi.deleteAssignment(request);
expect(result.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)
deleteResult, _, err := client.TasksApi.DeleteAssignment(ctx, &requests.DeleteAssignmentOpts{
AssignmentUid: 63,
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
})
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), deleteResult.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);
DeleteAssignmentRequest request1 = new DeleteAssignmentRequest(remoteFileName, 63, null, null, null);
AsposeResponse result1 = TestInitializer.tasksApi.deleteAssignment(request1);
assertNotNull(result1);
assertEquals(200, (int) result1.getCode());