Updating Custom fields added to a Project - API's
Hello Everyone
I am looking at updating a custom field using the POST method of Projects by passing in the specific Project ID.
I am able to update other system defined fields like "Name", I am trying to update the CustomField but this is not updating the data.
e.g. of the array that i am passing to update the Fields are
array("CustomeFieldValue:CustomField2;CustomeFieldValue"=>"Mario summary","Name"=>"Marios Test Project","Id"=>"e4035f06-a5d2-4339-981c-1f089e653395");
The first parameter is the CustomField2 i am trying to update. I have tried using the following options as well
CustomField2
CustomFieldValue:CustomeField2
The field "Name" does get updated
I have also added this as a separate post just so that it is open to community with the appropriate Title.
Thanks
Mario
-
Hi Mario,
I'm not sure if this is the issue but I see an e after Custom (CustomeFieldValue should be CustomFieldValue)
array("CustomeFieldValue:CustomField2;CustomeFieldValue"=>"Mario summary","Name"=>"Marios Test Project","Id"=>"e4035f06-a5d2-4339-981c-1f089e653395");
it should be
array("CustomeFieldValue:CustomField2;CustomFieldValue"=>"Mario summary","Name"=>"Marios Test Project","Id"=>"e4035f06-a5d2-4339-981c-1f089e653395");
Not sure if that is the cause but I did notice that would cause issue.
0 -
Hey Alex
The extra e was a typo while i was adding this issue. The code is without the "e"
$data_array = array("CustomFieldValue:CustomField2;CustomFieldValue"=>"mario summary","Name"=>"mario","Id"=>"e4035f06-a5d2-4339-981c-1f089e653395");
I do not receive any error it returns the following success string
array(6) { ["SavedId"]=> string(36) "e4035f06-a5d2-4339-981c-1f089e653395" ["SavedCount"]=> int(1) ["Success"]=> bool(true) ["SaveIdAlternate"]=> NULL ["Errors"]=> array(0) { } ["HasErrors"]=> bool(false) }
but the data is not updating in the customfield2 text box. Is there a different way i need to reference the customfield2 for saving?
Thanks
Mario
1 -
Hello,
I have never use the API using an array like. The way I normally do it is using our c# client or passing in json. The json i would pass for this would be
{
"Id": "e4035f06-a5d2-4339-981c-1f089e653395",
"Name": "Marios Test Project",
"CustomFieldValue": {
"CustomField2": "Mario summary"
}}
The CustomField2 is a string within the object of CustomFieldValue within a project. So you will have to show that accordingly. I am not sure how you would do that in an array as you are doing.
0 -
Thanks Fernando,
This worked for me.. Just pasting the webservice call here as it could be helpful for someone trying to update the data via services via PHP
$make_call = callAPI('POST', 'https://prothoughts-demo.projectinsight.net/api/project/', '{"Id": "e4035f06-a5d2-4339-981c-1f089e653395","Name": "Marios Test Project","CustomFieldValue": {"CustomField2": "Mario summary 123"}}');
$response = json_decode($make_call, true);echo var_dump($response);
Thanks
Mario
0
Please sign in to leave a comment.
Comments
4 comments