Get a Document Property by Name Introduction
This example explains how to get a document property by name, 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}/documentproperties/{propertyName}
GET
Read property by name
GetDocumentProperty
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("Home move plan.mpp");
var response = await TasksApi.GetDocumentPropertyAsync(new GetDocumentPropertyRequest
{
Name = remoteName,
Folder = this.DataFolder,
PropertyName = "Title"
});
Assert.AreEqual((int)HttpStatusCode.OK, response.Code);
Assert.IsNotNull(response.Property);
Assert.AreEqual("Title", response.Property.Name);
Assert.AreEqual("Home Move", response.Property.Value);
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 = "GetDocumentProperty.mpp";
$folder = $this->uploadFile("Home move plan.mpp", $remoteName, '');
$response = $this->tasks->getDocumentProperty(new Requests\GetDocumentPropertyRequest($remoteName, "Title", self::$storageName, $folder));
Assert::assertEquals(200, $response->getCode());
Assert::assertNotNull($response->getProperty());
Assert::assertEquals("Title", $response->getProperty()->getName());
Assert::assertEquals("Home Move", $response->getProperty()->getValue());
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 = 'Home_move_plan.mpp'
self.upload_file(filename)
request = GetDocumentPropertyRequest(filename, 'Title')
result = self.tasks_api.get_document_property(request)
self.assertIsNotNone(result)
self.assertIsInstance(result, DocumentPropertyResponse)
self.assertIsNotNone(result._property)
self.assertEqual('Title', result._property.name)
self.assertEqual('Home Move', result._property.value)
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 = "Home_move_plan.mpp";
const localPath = "./Data/" + fileName;
const remotePath = "Temp/Data";
const remoteFullPath = remotePath + "/" + fileName;
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
const request = new GetDocumentPropertyRequest();
request.name = fileName;
request.folder = remotePath;
request.propertyName = "Title";
const result = await tasksApi.getDocumentProperty(request);
expect(result.response.statusCode).to.equal(200);
expect(result.body.property).is.not.null.and.not.undefined;
expect(result.body.property.name).to.equal("Title");
expect(result.body.property.value).to.equal("Home Move");
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.GetDocumentPropertyOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
PropertyName: "Title",
}
result, _, err := client.TasksApi.GetDocumentProperty(ctx, options)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), result.Code)
assert.NotNil(t, result.Property)
assert.Equal(t, "Title", result.Property.Name)
assert.Equal(t, "Home Move", result.Property.Value)
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 = "Home_move_plan.mpp";
String remoteFileName = TestInitializer.UploadFile(localFileName);
GetDocumentPropertyRequest request = new GetDocumentPropertyRequest(remoteFileName, "Title", null, null);
DocumentPropertyResponse result = TestInitializer.tasksApi.getDocumentProperty(request);
assertNotNull(result);
assertEquals(200, (int) result.getCode());
assertNotNull(result.getProperty());
assertEquals("Title", result.getProperty().getName());
assertEquals("Home Move", result.getProperty().getValue());