Creating Schedule whit APISchedule

Discussion for TimeTrex open source community developers.
Post Reply
jhonathanarroyo
Posts: 6
Joined: Tue Dec 07, 2021 2:28 pm

Creating Schedule whit APISchedule

Post 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.
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: Creating Schedule whit APISchedule

Post 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?
jhonathanarroyo
Posts: 6
Joined: Tue Dec 07, 2021 2:28 pm

Re: Creating Schedule whit APISchedule

Post by jhonathanarroyo »

The response is:

bool(false)
Last edited by jhonathanarroyo on Wed Mar 02, 2022 10:19 am, edited 1 time in total.
jhonathanarroyo
Posts: 6
Joined: Tue Dec 07, 2021 2:28 pm

Re: Creating Schedule whit APISchedule

Post by jhonathanarroyo »

Could you send to me an example of how can I send a correct request to that API method?
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: Creating Schedule whit APISchedule

Post 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.
jhonathanarroyo
Posts: 6
Joined: Tue Dec 07, 2021 2:28 pm

Re: Creating Schedule whit APISchedule

Post 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
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: Creating Schedule whit APISchedule

Post 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.
Post Reply