How to POST appointment with JSON?

126 views
Skip to first unread message

Айдын Темеков

unread,
Oct 12, 2018, 5:37:34 AM10/12/18
to Easy!Appointments - Support Group

Hello!
I can't send POST to create new appointment with JSON.
Who did this?
Do I need to send something like this?
https://sd.shopuchet.kz/index.php/api/v1/appointments?[{"id": 6,       "book": "2018-09-24 16:53:01",       "start": "2018-10-10 11:45:00",       "end": "2018-10-10 12:15:00",       "notes": null,       "customerId": 13,       "providerId": 9,       "serviceId": 2,       "googleCalendarId": null}]

But it's not working.... How can I test it in something like SOAPUI?

Jorge Garrido

unread,
Dec 1, 2018, 5:34:44 PM12/1/18
to Easy!Appointments - Support Group
I've been testing and I know that it has to be done with ajax, but I'm getting error 500 (internal server error) in the result of the ajax call.

However if I do it with the curl command I'm successful.

In the next link there are som documentation for the restfull API:


For the ajax code contact me with pm for help.

Bye

Jorge Garrido

unread,
Dec 3, 2018, 12:09:40 AM12/3/18
to Easy!Appointments - Support Group
Hi, Finally I have achieve to post appointments through pure JSON from the Browser with JavaScript.

I advise you to do tests with CURL command. For example:

For get appointments use the following command:

The previous command will show you by console all the appointments in JSON format registered in EA.


For get customers use the following command:
The previous command will show you by console all the customers in JSON format registered in EA.


For get avalilable hours for a specific date use the following command:

curl https://yourdomain.com/easyappointmentpath/index.php/api/v1/availabilities?providerId=2&serviceId=5[&date=2018-06-21] --user adminuser:password

The previous command will show you by console all the available hours considering the following: The provider with Id=2, the service with Id=5 and the date 06/21/2018. All in JSON format. The date is optional.

You can POST appointments but you have to create a new customer in case isn't registered in EA. I didn't find this in the documentation clearly. So I had to do several tests.

For search a customer by email you can use the following command:


You can use the name, last name or another value too.

For create customers you can use the followin command:

curl https://yourdomain.com/easyappointmentpath/index.php/api/v1/customers --user adminuser:password -X POST -d '{"firstName":"Julio","lastName": "Berne","email": "jb@domain","phone": "+56965736649","address": "","city": "","zip": "","notes": null}'

After you send this request to the server you will get a JSON response from the server like the following:

{
   
"id": 11,
   
"firstName": "Julio",
   
"lastName": "Berne",
   
"email": "jb@domain",
   
"phone": "+56965736649",
   
"address": null,
   
"city": null,
   
"zip": null,
   
"notes": null
}

And you will get a customer id (new custemer Id = 11) generated by the EA server.


Then the only thing missing is to create the appointment. You can do it with the following command:

curl https://yourdomain.com/easyappointmentpath/index.php/api/v1/appointments
 
--user adminuser:password -X POST -d '{"start": "2018-12-16 10:00:00","end": "2018-12-16 11:00:00","customerId": 11,"providerId": 2,"serviceId": 1}'

You will get a JSON response like following:

{
   
"id": 19,
   
"book": "2018-12-03 04:55:26",
   
"start": "2018-12-16 10:00:00",
   
"end": "2018-12-16 11:00:00",
   
"hash": "7a36dc51ff12b8ea841212ab571ae6ee",
   
"notes": null,
   
"customerId": 11,
   
"providerId": 2,
   
"serviceId": 1,
   
"googleCalendarId": null
}

I haven't
tried integrating EA with google calendars yet. You only need adapt this commands to your JS code... which is the funniest part!!!

Hope this can help you

Bye.


Reply all
Reply to author
Forward
0 new messages