Edit Document Property Introduction
This example explains how to edit document property, 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}
PUT
Update a property in a MS Project File
PutDocumentProperty
cURL Example
Request
Copy
curl - X PUT "https://api.aspose.cloud/v3.0/tasks/Home_move_plan.mpp/documentproperties/Title" - H "accept: application/json" - H "Content-Type: application/json" - H "x-aspose-client: Containerize.Swagger" - d "{ \"link\": { \"href\": \"string\", \"rel\": \"string\", \"type\": \"string\", \"title\": \"string\" }, \"name\": \"string\", \"value\": \"string\"}"
Response
Copy
{
"code" : 0 ,
"status" : "string" ,
"property" : {
"link" : {
"href" : "string" ,
"rel" : "string" ,
"type" : "string" ,
"title" : "string"
},
"name" : "string" ,
"value" : "string"
}
}
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 putResponse = await TasksApi.PutDocumentPropertyAsync(new PutDocumentPropertyRequest
{
Name = remoteName,
Folder = this.DataFolder,
PropertyName = "Title",
Property = new DocumentProperty
{
Name = "Title",
Value = "New title value"
}
});
var response = await TasksApi.GetDocumentPropertiesAsync(new GetDocumentPropertiesRequest
{
Name = remoteName,
Folder = this.DataFolder
});
Assert.AreEqual((int)HttpStatusCode.OK, response.Code);
Assert.AreEqual(52, response.Properties.List.Count);
Assert.AreEqual("Title", response.Properties.List[0].Name);
Assert.AreEqual("New title value", response.Properties.List[0].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 = "EditDocumentProperty.mpp";
$folder = $this->uploadFile("Home move plan.mpp", $remoteName, '');
$property = new DocumentProperty();
$property->setName("Title");
$property->setValue("New title value");
$response = $this->tasks->putDocumentProperty(new Requests\PutDocumentPropertyRequest($remoteName, "Title", $property, self::$storageName, $folder, null));
Assert::assertEquals(200, $response->getCode());
$response = $this->tasks->getDocumentProperties(new Requests\GetDocumentPropertiesRequest($remoteName, self::$storageName, $folder));
Assert::assertEquals(200, $response->getCode());
Assert::assertEquals(52, count($response->getProperties()->getList()));
foreach($response->getProperties()->getList() as $p)
{
if($p->getName() == "Title")
{
$found = true;
Assert::assertEquals("New title value", $p->getValue());
break;
}
}
Assert::isTrue($found);
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)
_property = DocumentProperty('Title', 'New title value')
put_request = PutDocumentPropertyRequest(filename, 'Title', _property)
self.tasks_api.put_document_property(put_request)
get_request = GetDocumentPropertyRequest(filename, 'Title')
result = self.tasks_api.get_document_property(get_request)
self.assertIsNotNone(result)
self.assertIsInstance(result, DocumentPropertyResponse)
self.assertIsNotNone(result._property)
self.assertEqual('Title', result._property.name)
self.assertEqual('New title value', 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 property = new DocumentProperty();
property.name = "Title";
property.value = "New title value";
const request = new PutDocumentPropertyRequest();
request.name = fileName;
request.folder = remotePath;
request.propertyName = "Title";
request.property = property;
await tasksApi.putDocumentProperty(request);
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)
putOptions := &requests.PutDocumentPropertyOpts{
Name: remoteFileName,
Folder: optional.NewString(remoteBaseTestDataFolder),
PropertyName: "Title",
Property: models.DocumentProperty{
Name: "Title",
Value: "New title value",
},
}
putResult, _, err := client.TasksApi.PutDocumentProperty(ctx, putOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putResult.Code)
assert.NotNil(t, putResult.Property)
assert.Equal(t, "Title", putResult.Property.Name)
assert.Equal(t, "New title value", putResult.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);
DocumentProperty property = new DocumentProperty();
property.setName("Title");
property.setValue("New title value");
PutDocumentPropertyRequest request = new PutDocumentPropertyRequest(remoteFileName, property.getName(), property, null, null, null);
DocumentPropertyResponse result = TestInitializer.tasksApi.putDocumentProperty(request);
assertNotNull(result);
assertEquals(200, (int) result.getCode());