Page 1 of 1

Creating Schedule whit APISchedule

Posted: Tue Mar 01, 2022 4:05 pm
by jhonathanarroyo
Could someone help me to know what am I doing wrong

Code: Select all

$dataSchedule = [               
							'user_id' => 'iduser',                
							'status_id' => 20, //Absent               
							'start_date' => strtotime($data->dtstart->format('Y-m-d H:i:s')),
							'end_date' => strtotime($data->dtend->format('Y-m-d H:i:s')),
							'absence_policy_id' => 'idpolicy'
						];
$user_data = $this->postToURL( $this->buildURL( 'APISchedule', 'setSchedule', TRUE ), [ $arguments ] );
 
is not saving and is not returning error.

Re: Creating Schedule whit APISchedule

Posted: Tue Mar 01, 2022 5:45 pm
by shaunw
We will need more to go on, like what is the full and exact output displayed on the screen when you run that code? What is does var_dump($user_data); show?

Re: Creating Schedule whit APISchedule

Posted: Wed Mar 02, 2022 10:16 am
by jhonathanarroyo
The response is:

bool(false)

Re: Creating Schedule whit APISchedule

Posted: Wed Mar 02, 2022 10:18 am
by jhonathanarroyo
Could you send to me an example of how can I send a correct request to that API method?

Re: Creating Schedule whit APISchedule

Posted: Wed Mar 02, 2022 10:30 am
by shaunw
Turn on debug logging in the timetrex.ini.php file, then attach a copy of the log here that includes the API request you are trying to make.

Re: Creating Schedule whit APISchedule

Posted: Thu Mar 03, 2022 9:45 am
by jhonathanarroyo
I do not have access to the server.

Could you send to me an example of the parameters needed in the argument to send the request to the APISchedule -> setSchedule

Thanks

Re: Creating Schedule whit APISchedule

Posted: Thu Mar 03, 2022 12:36 pm
by shaunw
Normally if the data you are sending is incorrect, you would get a detailed error message as to why that is the case. Because you are not receiving that, its likely that something larger is wrong, such as invalid URL, API key/SessionID, or the end-point you are calling into is incorrect.

The api/json/api_client_example.php script will work against our public demo instance of TimeTrex. So you should be able to use that to create a test schedule if you like.