[#675] JSON RPC GetBookings

Migrated from Redmine #675 | Author: Craig Jackson
Status: New | Priority: High, I’m very impatient | Created: 2021-03-24


Can anyone see what I am doing wrong here? Thanks

$headers = @{

    'X-Company-Login' = 'xxxx';
    'X-Token' = 'xxxx'

};

$Body = @{
jsonrpc = ‘2.0’;
method = ‘getBookings’;
params = @{

    date_from = '2020-12-29'
    date_to = '2021-12-29'       
    order = 'start_date'
};
id      = [guid]::NewGuid()

} | ConvertTo-Json
$data = Invoke-WebRequest -Uri ‘https://user-api-v2.nhsbookings.com/admin/’ -Method ‘POST’ -Header $headers -Body $Body

Redmine Admin wrote:

it seems you are mixing user API and REST API, please read docs here and do calls accrodingly API documentation | SimplyBook.me Online Scheduling

Craig Jackson wrote:

Redmine Admin wrote:

it seems you are mixing user API and REST API, please read docs here and do calls accrodingly API documentation | SimplyBook.me Online Scheduling

Could you advise please - the documentation is not very clear

Redmine Admin wrote:

what is not clear in documentation?

Craig Jackson wrote:

Redmine Admin wrote:

what is not clear in documentation?

Pretty much everything - I am new to Rest and JSONRPC Api’s. If you could point out where I have gone wrong it would be very much appreciated

Redmine Admin wrote:

Please start from Authentication section and then go to API documentation | SimplyBook.me Online Scheduling

feel free to ask any questions.

Craig Jackson wrote:

Redmine Admin wrote:

API documentation | SimplyBook.me Online Scheduling

Please start from Authentication section and then go to API documentation | SimplyBook.me Online Scheduling

feel free to ask any questions.

Ok - so I managed to get this running - however only gives me some meta data

$uri = “https://user-api-v2.nhsbookings.com/admin/bookings

$headers = @{

‘X-Company-Login’ = ‘russelshallpod1’
‘X-Token’ = “xxxxxx”
}

Write-Output $data = Invoke-RestMethod -Uri “${uri}” -ContentType application/json -Method GET -Header $headers #-OutFile “c:\temp\report.json”

Output
data : {@{provider=; service=; client=; status=canceled; membership_id=; invoice_id=; invoice_status=; invoice_payment_received=False;
invoice_number=; invoice_datetime=; invoice_payment_processor=; ticket_code=; ticket_validation_datetime=; ticket_is_used=False;
user_status_id=; category_id=; location_id=; category=; location=; can_be_edited=False; can_be_canceled=False; id=1; code=0340dto;
start_datetime=2020-12-22 10:45:00; end_datetime=2020-12-22 10:55:00; service_id=1; provider_id=19; client_id=4; duration=10},
@{provider=; service=; client=; status=canceled; membership_id=; invoice_id=; invoice_status=; invoice_payment_received=False;
invoice_number=; invoice_datetime=; invoice_payment_processor=; ticket_code=; ticket_validation_datetime=; ticket_is_used=False;
user_status_id=; category_id=; location_id=; category=; location=; can_be_edited=False; can_be_canceled=False; id=2; code=0341q5g;
start_datetime=2020-12-22 13:00:00; end_datetime=2020-12-22 13:10:00; service_id=1; provider_id=19; client_id=4; duration=10},
@{provider=; service=; client=; status=canceled; membership_id=; invoice_id=; invoice_status=; invoice_payment_received=False;
invoice_number=; invoice_datetime=; invoice_payment_processor=; ticket_code=; ticket_validation_datetime=; ticket_is_used=False;
user_status_id=; category_id=; location_id=; category=; location=; can_be_edited=False; can_be_canceled=False; id=3; code=0342p8w;
start_datetime=2020-12-29 08:00:00; end_datetime=2020-12-29 08:10:00; service_id=1; provider_id=20; client_id=4; duration=10},
@{provider=; service=; client=; status=canceled; membership_id=; invoice_id=; invoice_status=; invoice_payment_received=False;
invoice_number=; invoice_datetime=; invoice_payment_processor=; ticket_code=; ticket_validation_datetime=; ticket_is_used=False;
user_status_id=; category_id=; location_id=; category=; location=; can_be_edited=False; can_be_canceled=False; id=4; code=0343zap;
start_datetime=2020-12-29 20:00:00; end_datetime=2020-12-29 20:10:00; service_id=1; provider_id=19; client_id=104; duration=10}…}
metadata : @{items_count=25230; pages_count=2523; page=1; on_page=10}

=

Dmytro Bondarev wrote:

It is list of bookings. It is not a meta data.

Craig Jackson wrote:

Dmitry Bondarev wrote:

It is list of bookings. It is not a meta data.

Yeah just noticed that - Only seems to be bringing back a few? I need it to bring back everything in there

Dmytro Bondarev wrote:

Not possible to get all bookings with one request.
You have to make multiple requests one by one, passing page number.

Craig Jackson wrote:

Dmitry Bondarev wrote:

Not possible to get all bookings with one request.
You have to make multiple requests one by one, passing page number.

Ok that could work - Thanks

Craig Jackson wrote:

Craig Jackson wrote:

Dmitry Bondarev wrote:

It is list of bookings. It is not a meta data.

Yeah just noticed that - Only seems to be bringing back a few? I need it to bring back everything in there

How would I specify a page number to view?

Dmytro Bondarev wrote:

As mentioned here API documentation | SimplyBook.me Online Scheduling
Just use /admin/bookings?page={your_page_number}

Craig Jackson wrote:

Dmitry Bondarev wrote:

As mentioned here API documentation | SimplyBook.me Online Scheduling
Just use /admin/bookings?page={your_page_number}

Doesnt seem to work, I have tried passing different page numbers and produces the same list of data

eg
https://user-api-v2.nhsbookings.com/admin/bookings?Page=3

Redmine Admin wrote:

page must be in lower case

Craig Jackson wrote:

Redmine Admin wrote:

page must be in lower case

Ahhh Fantastic - thats working now. Thanks very much

Craig Jackson wrote:

Craig Jackson wrote:

Redmine Admin wrote:

page must be in lower case

Ahhh Fantastic - thats working now. Thanks very much

Thanks for your help today - but think I need to rethink. Is there a way I can only extract those that have been changed or created on a specific day?

Redmine Admin wrote:

please check docs (links above) for available filters, hope it will give you some glue

Craig Jackson wrote:

Redmine Admin wrote:

please check docs (links above) for available filters, hope it will give you some glue

Unable to find anything that will bring back everything that was changed on a filtered day?