Post

1 follower Follow
0
Avatar

Query to insert work hours in Work field in PHP

Hi,

Please help to insert hours in Work field while creating task. I am facing issue in below code snippet:

 $thrs =  $this->input->post('hrs');

      $type = new stdClass();

       $type->FieldName = "Work";

    $tduration = array ( "Value" => $thrs);

  $type->Value = new SoapVar($tduration, SOAP_ENC_OBJECT, "Duration","http://www.w3.org/2001/XMLSchema");

its giving below error:

<b>Fatal error</b>:  Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception

while trying to deserialize the message: There was an error while trying to deserialize parameter http

://clarizen.com/api:request. The InnerException message was 'Error in line 2 position 998. Element 'http

://clarizen.com/api:Value' contains data from a type that maps to the name 'http://www.w3.org/2001/XMLSchema

:Duration'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver

or add the type corresponding to 'Duration' to the list of known types - for example, by using the KnownTypeAttribute

attribute or by adding it to the list of known types passed to DataContractSerializer.'

Thanks,

Shivani

Shivani Gupta Answered

Please sign in to leave a comment.

4 comments

0
Avatar

Hi Shivani,

Here's a sample for using duration field. Note that it has to have the Unit and Value properties and it's defined in the Clarizen API namespace:

$duration_value = array ("Unit"=>"Hours", "Value" => "2");

$duration = new stdClass();

$duration->FieldName = 'Work';

$duration->Value = new SoapVar($duration_value, SOAP_ENC_OBJECT, "Duration","http://clarizen.com/api");

 

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

Hi,

Thanks for your response. I am still facing below error with same code:

<b>Fatal error</b>:  Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception

while trying to deserialize the message: There was an error while trying to deserialize parameter http

://clarizen.com/api:request. The InnerException message was 'Element Value from namespace http://clarizen

.com/api cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize

this pattern of XML.'.  Please see InnerException for more details. in /a

pplication/controllers/ajax.php:342

Please help!Thanks,Shivani

Shivani Gupta 0 votes
Comment actions Permalink
0
Avatar

Hi,

 

I am facing an error now with same piece of code. Can you help?

Field 'Duration' in Task 'header changes' cannot have negative value
Shivani Gupta 0 votes
Comment actions Permalink
0
Avatar

Hi Shivani,

Did you manage the first error (...Please use XmlNode[] ...)?

As for the Field 'Duration' in Task 'header changes' cannot have negative value it means your PHP did send the update to Clarizen, and it failed validation there. Check the combination of Start Date, Due Date and Duration values in the Update you sent to figure out why the Duration value came out negative. 

If you have an error reference code, please send it, so I can check the logs.

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink