Free and Premium WordPress Plugins & Themes Forums WordPress Plugins Hotel Booking GET request to API, invalid parameter
- This topic has 9 replies, 3 voices, and was last updated 10 months, 1 week ago by eric godart.
- AuthorPosts
- November 25, 2023 at 7:51 am #1534471eric godartParticipant
Hello,
I am using the API GET request to retrieve a list of bookings in Motopress.
If I use this url request, it is ok: https://hbdemo.getmotopress.com/your-demo-id/wp-json/mphb/v1/bookings?context=view&page=1&per_page=5
Now if I want to get only bookings from 2022-08-08 I tried this url request (according to REST API documention) in my python script:
https://hbdemo.getmotopress.com/your-demo-id/wp-json/mphb/v1/bookings?context=view&page=1&per_page=5&after=2022-08-08return is:
code rest_invalid_param message Paramètre(s) invalide(s) : « after » message_tre s message_invalide s data status 400 params after Date non valide. details after code rest_invalid_date message Date non valide. data
Basically it says that “after” is not a valid parameter. Can you help ?
Thanks !
December 1, 2023 at 5:03 am #1538922eric godartParticipant5 days ? no reply ?
Is this place supposed to be a technical support place ?December 13, 2023 at 7:36 am #1544803J. DavisKeymasterHi, you can use the example of the filter to get the bookings for a certain period:
{ "filter":{ "meta_query":{ "relation":"AND", "date":{ "key":"mphb_check_in_date", "value":[ "2022-10-26", "2023-10-27" ], "compare":"BETWEEN", "type":"DATE" } } } }
December 18, 2023 at 12:39 am #1546435eric godartParticipantHi,
Have you tried this filter yourself ?
I just tried it both on my website and online on the demo and it gives me exactly the same result with or without the filter ???
It does not filter anything.Any suggestion ?
December 18, 2023 at 2:35 am #1546479Loris PlassonParticipantHello Eric,
Thanks for linking this thread.
I just tried on my side it doesn’t work, but the thing is I don’t know how to formulate the request, filter being an object, I don’t know if it should be in the parameters.
But since the API is always returning the same result as you said, we have no way of knowing what’s wrong.
Maybe an admin or a support member could give us a full cURL sample including the filter? That would definitely help.
Best Regards,
Loris
PS: (sorry for the duplicate I thought I was replying to the other thread)
December 18, 2023 at 12:21 pm #1546769eric godartParticipantfor information this is the command I used:
curl -X ‘GET’ \
‘https://hbdemo.getmotopress.com/xxxxxxxxxxxxxxxx/wp-json/mphb/v1/bookings?context=view&page=1&per_page=25&filter%5Bfilter%5D%5Bmeta_query%5D%5Brelation%5D=AND&filter%5Bfilter%5D%5Bmeta_query%5D%5Bdate%5D%5Bkey%5D=mphb_check_in_date&filter%5Bfilter%5D%5Bmeta_query%5D%5Bdate%5D%5Bvalue%5D=2022-10-26&filter%5Bfilter%5D%5Bmeta_query%5D%5Bdate%5D%5Bvalue%5D=2023-12-31&filter%5Bfilter%5D%5Bmeta_query%5D%5Bdate%5D%5Bcompare%5D=BETWEEN&filter%5Bfilter%5D%5Bmeta_query%5D%5Bdate%5D%5Btype%5D=DATE’ \
-H ‘accept: application/json’ \
-H ‘Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDecember 18, 2023 at 1:44 pm #1546806J. DavisKeymasterPlease check the screenshot to learn how to send a request with filter https://prnt.sc/Eo3A_aGV52oo
December 19, 2023 at 2:10 am #1546919eric godartParticipantit still does not filter anything.
Is it working for you ?
December 28, 2023 at 8:56 am #1550207J. DavisKeymasterHi, could you check if the default WordPress Rest API works correctly and if there are no issues at Tools > Site Health?
January 2, 2024 at 8:38 am #1551421eric godartParticipantFor anyone interedted about this subject:
this is the answer I got today by email
*********************************
John Davis (MotoPress)Jan 2, 2024, 02:02 EST
Hello Thierry,Thanks for your reply. I’ve consulted with our developers and they have found that complex nested requests can not be executed on our Rest API demo site https://motopress.github.io. Please test the request with a filter query in special software like Postman software and it should work correctly.
Best regards,
John Davis
MotoPress Support
**************************************So basically the filter does not work. I am a bit fed up to have to wait for so long to get such an answer.
I will make myself a python script to get all the orders and then filter them out.
Regards,
Thierry - AuthorPosts
- You must be logged in to reply to this topic.