Get UIDs of Projects in Multi-Project files Introduction
This example explains how to get UIDs of projects in multi-project files, 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}/projectids
GET
Get the project ID from a MS Project File
GetProjectIds
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("p6_multiproject.xml");
var response = await TasksApi.GetProjectIdsAsync(new GetProjectIdsRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual((int)HttpStatusCode.OK, response.Code);
CollectionAssert.AreEquivalent(new string[] { "1", "111" } , response.ProjectIds);
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 = "testGetProjectIds.xml";
$folder = $this->uploadFile("p6_multiproject.xml", $remoteName, '');
$response = $this->tasks->getProjectIds(new Requests\GetProjectIdsRequest($remoteName, self::$storageName, $folder));
Assert::assertEquals(200, $response->getCode());
Assert::assertEquals("1", $response->getProjectIds()[0]);
Assert::assertEquals("111", $response->getProjectIds()[1]);
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 = 'p6_multiproject.xml'
self.upload_file(filename)
get_request = GetProjectIdsRequest(filename)
get_result = self.tasks_api.get_project_ids(get_request)
self.assertIsNotNone(get_result)
self.assertIsInstance(get_result, ProjectIdsResponse)
self.assertEqual(['1', '111'], get_result.project_ids)
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 request = new GetProjectIdsRequest();
request.name = "imported_from_db.xml";
request.folder = "Temp/Data";
const result2 = await tasksApi.getProjectIds(request);
expect(result2.response.statusCode).to.equal(200);
expect(result2.body.projectIds).to.eql(["1"]);
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.GetProjectIdsOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
}
result, _, err := client.TasksApi.GetProjectIds(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.Equal(t, []string{"1", "111"}, result.ProjectIds)
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 = "p6_multiproject.xml";
String remoteFileName = TestInitializer.UploadFile(localFileName);
GetProjectIdsRequest request = new GetProjectIdsRequest(remoteFileName, null, null);
ProjectIdsResponse result = TestInitializer.tasksApi.getProjectIds(request);
assertNotNull(result);
assertEquals(200, result.getCode().intValue());
assertNotNull(result.getProjectIds());
assertEquals(Arrays.asList("1", "111"), result.getProjectIds());