Page 1 of 1

API Report data

Posted: Fri Mar 16, 2018 9:53 am
by fcoucello
Hello all,

Before I say anything, I want to congratulate the TimeTrex team for a great job on creating this amazing software!

I recently installed TimeTrex Community Edition to test it on the company where I'm a colaborator.
Im trying to create a simple routine aplication in C# to get weekly reports. Im following the workfore-management-api from https://www.timetrex.com/workforce-management-api.
I can get the config but im getting trouble on the report data, this is the response I get:
{"-1010-time_period":{"time_period":"last_pay_period"},"-1000-template":"by_employee regular overtime premium absence"}
{"api_retval":false,"api_details":{"code":"VALIDATION","description":"INVALID DATA","record_details":{"total":1,"valid":0,"invalid":1},"user_generic_status_batch_id":false,"details":[{"time_period":["No time period defined for this report"],"columns":["No columns specified to display on report"]}]}}
it says I didnt choose any time period nor columns.
$result = postToURL( buildURL( 'APITimesheetSummaryReport', 'getTimesheetSummaryReport' ), array( $config, 'raw' ) );
with raw or wihout it i get the same response.
Im sure Im missing something some parameters I guess.

Re: API Report data

Posted: Fri Mar 16, 2018 10:03 am
by mikeb
Can you post the raw HTTP request that you are sending to the API?

Re: API Report data

Posted: Fri Mar 16, 2018 10:28 am
by fcoucello
http://<timetrexserver>/api/json/api.php?Class=APITimesheetSummaryReport&Method=getTimesheetSummaryReport&SessionID=\"7a4dcbdce25b480ace9b3f7c06d497fd6675eb2e\"&json={\"-1010-time_period\":{\"time_period\":\"last_pay_period\"},\"-1000-template\":\"by_employee regular overtime premium absence\"}
if I do it on the browser it shows a blank page

Re: API Report data

Posted: Fri Mar 16, 2018 4:19 pm
by mikeb
The JSON data cannot be included on the URL, it must be included in the body of the POST request instead.

Re: API Report data

Posted: Mon Mar 19, 2018 8:05 am
by fcoucello
Here is some PrintScreens...

Re: API Report data

Posted: Mon Mar 19, 2018 8:46 am
by mikeb
The body must be formatted with the "json" POST variable containing the raw JSON data, similar to this:

Code: Select all

json={"user_name": "myuser", "password": "mypassword"}

Re: API Report data

Posted: Mon Mar 19, 2018 10:40 am
by fcoucello
Then Your saying that it must be in the url not in body....

Re: API Report data

Posted: Mon Mar 19, 2018 3:25 pm
by mikeb
fcoucello wrote: Mon Mar 19, 2018 10:40 am Then Your saying that it must be in the url not in body....
That is incorrect, it must be in the body of the POST request.


You can simply make a call like this:

URL: https://demo.timetrex.com/next-release/ ... thod=Login
Body:

Code: Select all

json={ "user_name": "demoadmin1", "password": "demo" }
You can use this site (https://resttesttest.com/) to test the above example as well, by simply clicking on the "Add Parameter" button, giving it a name of "json" and value of "{ "user_name": "demoadmin1", "password": "demo" }"