Get Project Assignment Items Introduction
This example explains how to read assignment information from a MS Project file 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
GET
Read assignment information from a MS Project File
GetAssignments
cURL Example
Request
Copy
curl - v "https://api.aspose.cloud/connect/token" - X POST - d "grant_type=client_credentials&client_id=XXXXX&client_secret=XXXXX" - H "Content-Type: application/x-www-form-urlencoded" - H "Accept: application/json"
Copy
curl - X GET "https://api.aspose.cloud/v3.0/tasks/project_2013.mpp/assignments" - H "accept: application/json"
Response
Copy {
"code" : 0 ,
"status" : "string" ,
"assignments" : {
"link" : {
"href" : "string" ,
"rel" : "string" ,
"type" : "string" ,
"title" : "string"
},
"assignmentItem" : [
{
"link" : {
"href" : "string" ,
"rel" : "string" ,
"type" : "string" ,
"title" : "string"
},
"uid" : 0 ,
"taskUid" : 0 ,
"resourceUid" : 0
}
]
}
}
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.GetAssignmentsAsync(new GetAssignmentsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual((int)HttpStatusCode.OK, response.Code);
Assert.IsNotNull(response.Assignments);
Assert.AreEqual(6, response.Assignments.AssignmentItem.Count);
Assert.AreEqual(34, response.Assignments.AssignmentItem[0].TaskUid);
Assert.AreEqual(63, response.Assignments.AssignmentItem[0].Uid);
Assert.AreEqual("/63", response.Assignments.AssignmentItem[0].Link.Href);
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 = "GetAssignments.mpp";
$folder = $this->uploadFile("NewProductDev.mpp", $remoteName, '');
$request = new Requests\GetAssignmentsRequest($remoteName, self::$storageName, $folder);
$result = $this->tasks->getAssignments($request);
Assert::assertEquals(200, $result->getCode());
Assert::assertNotNull($result->getAssignments());
Assert::assertEquals(6, count($result->getAssignments()->getAssignmentItem()));
Assert::assertEquals(34, $result->getAssignments()->getAssignmentItem()[0]->getTaskUid());
Assert::assertEquals(63, $result->getAssignments()->getAssignmentItem()[0]->getUid());
Assert::assertEquals("/63", $result->getAssignments()->getAssignmentItem()[0]->getLink()->getHref());
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)
result = self.tasks_api.get_assignments(GetAssignmentsRequest(filename))
self.assertIsInstance(result, AssignmentItemsResponse)
self.assertIsNotNone(result.assignments)
self.assertEqual(6, len(result.assignments.assignment_item))
self.assertEqual(34, result.assignments.assignment_item[0].task_uid)
self.assertEqual(63, result.assignments.assignment_item[0].uid)
self.assertEqual("/63", result.assignments.assignment_item[0].link.href)
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 request = new GetAssignmentsRequest();
request.name = fileName;
request.folder = remotePath;
const result = await tasksApi.getAssignments(request);
expect(result.response.statusCode).to.equal(200);
expect(result.body.assignments).not.undefined.and.not.null;
expect(result.body.assignments.assignmentItem.length).to.equal(6);
expect(result.body.assignments.assignmentItem[0].taskUid).to.equal(34);
expect(result.body.assignments.assignmentItem[0].uid).to.equal(63);
expect(result.body.assignments.assignmentItem[0].link.href).to.equal("/63");
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)
options := &requests.GetAssignmentsOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetAssignments(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Assignments)
assert.Equal(t, 6, len(result.Assignments.AssignmentItem))
assert.Equal(t, int32(34), result.Assignments.AssignmentItem[0].TaskUid)
assert.Equal(t, int32(63), result.Assignments.AssignmentItem[0].Uid)
assert.Equal(t, "/63", result.Assignments.AssignmentItem[0].Link.Href)
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);
GetAssignmentsRequest request = new GetAssignmentsRequest(remoteFileName, null, null);
AssignmentItemsResponse result = TestInitializer.tasksApi.getAssignments(request);
assertNotNull(result);
assertEquals(200, (int) result.getCode());
assertNotNull(result.getAssignments());
assertEquals(6, result.getAssignments().getAssignmentItem().size());
assertEquals(new Integer(34), result.getAssignments().getAssignmentItem().get(0).getTaskUid());
assertEquals(new Integer(63), result.getAssignments().getAssignmentItem().get(0).getUid());
assertEquals("/63", result.getAssignments().getAssignmentItem().get(0).getLink().getHref());