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.
API Report data
Re: API Report data
Can you post the raw HTTP request that you are sending to the API?
Re: API Report data
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
if I do it on the browser it shows a blank page
Re: API Report data
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
Here is some PrintScreens...
- Attachments
-
- With json on body2
- restapi3.png (25.2 KiB) Viewed 55130 times
-
- With json on url
- restapi2.png (20.82 KiB) Viewed 55130 times
-
- With json on body
- restapi.png (24.22 KiB) Viewed 55130 times
Re: API Report data
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
Then Your saying that it must be in the url not in body....
Re: API Report data
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" }