API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Create Time Entry

0

Greetings.

 

Trying to create a timeentry in a project. Gets this error:

PHP Fatal error:  Uncaught SoapFault exception: [soap:Client] Economic.Api.Exceptions.ValidationException(E04010): Null data entities not allowed when creating or updating entities. (id=d5a05660-258a-4623-99eb-a55fbf4d8eda) 

 

Code: $client->TimeEntry_CreateFromData($invoice_data);

Array ($invoice_data): 
array(10) {
  ["Handle"]=>
  string(1) "1"
  ["Id"]=>
  string(1) "1"
  ["ProjectHandle"]=>
  string(1) "1"
  ["EmployeeHandle"]=>
  string(1) "1"
  ["Date"]=>
  string(10) "2016-08-18"
  ["Text"]=>
  string(37) "Ticket: 52#1008 : adsfasdfas adf adsf"
  ["NumberOfHours"]=>
  string(5) "10:00"
  ["Approved"]=>
  bool(true)
  ["SalesPrice"]=>
  int(0)
  ["CostPrice"]=>
  int(0)
}

 

Anyone?

 

created Aug 18, 2016 by osomanden
0% Accept Rate
Q 4 A 0 C 1

1 Answer

0

Hi Osomanden

Null data entities not allowed means you've sent in an empty entity.

Here's your XML from the logs:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://e-conomic.com"><SOAP-ENV:Body><ns1:TimeEntry_CreateFromData/></SOAP-ENV:Body></SOAP-ENV:Envelope>

While building your solution it is often a good idea to setup debug logging that logs your entire outgoing messages so you can get the full insight into what you actually transferred over the pipes.

A great tool for this is Fiddler, which is a free proxy tool.
They have a guide for using it with PHP here: 
http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/ConfigurePHPcURL

answered Aug 18, 2016 by olej
It was a combination of command and array:

$client->TimeEntry_CreateFromData(array( "data"=>$invoice_data))->TimeEntry_CreateFromDataResult;

And build of array:

                $invoice_data = array(
                    "Handle" => array("Id" => $invoice_project_id),
                    "Id"  => array("Number" => $invoice_project_id),
                    "ProjectHandle" => array("Number" => $invoice_project_id),
                    "EmployeeHandle" => array("Number" => $_SESSION["u_id"]),
                    "Date" => date("c"),
                    "Text" => "Ticket: ".$ticket_id."#".$followup_id." : ".$invoice_text,
                    "NumberOfHours" => str_replace(":",".",$_POST["additional_time"]),
                    "Approved" => TRUE,
                    "SalesPrice" => "0.0",
                    "CostPrice" => "0.0"
                );
Visma e-conomic A/S
...