Testdriving RESTful APIs - help needed Topic is solved
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
- aftertaf
- Joomla! Apprentice
- Posts: 14
- Joined: Sat Jan 23, 2010 1:27 pm
- Contact:
Testdriving RESTful APIs - help needed
Hi,
I'm trying to test out the RESTful APIs in J!4.0.4, following the instructions here : https://magazine.joomla.org/all-issues/ ... taste-test
UsingPostman, i cannot get past this stage :
"Finally, use one of the GET endpoints to test that your endpoints are connecting to your site."
I get systematically a 404 :
{
"title": "Resource not found",
"code": 404
}
I've tried with 2 valid superusers' API keys, no joy.
When I remove all the text after base_path, i get a HTTP 200 and can reach the website OK.
{{base_path}}/api/index.php/v1/content/articles/ : NOK
{{base_path}} : OK
ACCESS logs:
54.86.50.139 - - [02/Dec/2021:00:34:37 +0100] "GET / HTTP/1.1" 200 13511 "-" "PostmanRuntime/7.28.4"
54.86.50.139 - - [02/Dec/2021:00:34:26 +0100] "GET /api/v1/content HTTP/1.1" 404 65 "-" "PostmanRuntime/7.28.4"
54.86.50.139 - - [02/Dec/2021:00:34:12 +0100] "GET /api/v1/content/articles/ HTTP/1.1" 404 65 "-" "PostmanRuntime/7.28.4"
54.86.50.139 - - [02/Dec/2021:00:33:58 +0100] "GET /api/index.php/v1/content/articles/ HTTP/1.1" 404 65 "-" "PostmanRuntime/7.28.4"
54.86.50.139 - - [01/Dec/2021:23:56:08 +0100] "POST /api/index.php/v1/content/article HTTP/1.1" 404 65 "-" "PostmanRuntime/7.28.4"
x.x.x.x - - [01/Dec/2021:23:55:40 +0100] "POST /api/index.php/v1/content/article HTTP/1.1" 406 40 "-" "Mozilla/5.0 (Windows NT; Windows NT 10.0; fr-FR) WindowsPowerShell/5.1.19041.1320"
I've checked all the system plugins are enables, CORS is enabled, but cannot find any other documentation online to troubleshoot more.
Any pointers highly appreciated.
(if any more info / details needed please don't hesitate !!)
Thanks
I'm trying to test out the RESTful APIs in J!4.0.4, following the instructions here : https://magazine.joomla.org/all-issues/ ... taste-test
UsingPostman, i cannot get past this stage :
"Finally, use one of the GET endpoints to test that your endpoints are connecting to your site."
I get systematically a 404 :
{
"title": "Resource not found",
"code": 404
}
I've tried with 2 valid superusers' API keys, no joy.
When I remove all the text after base_path, i get a HTTP 200 and can reach the website OK.
{{base_path}}/api/index.php/v1/content/articles/ : NOK
{{base_path}} : OK
ACCESS logs:
54.86.50.139 - - [02/Dec/2021:00:34:37 +0100] "GET / HTTP/1.1" 200 13511 "-" "PostmanRuntime/7.28.4"
54.86.50.139 - - [02/Dec/2021:00:34:26 +0100] "GET /api/v1/content HTTP/1.1" 404 65 "-" "PostmanRuntime/7.28.4"
54.86.50.139 - - [02/Dec/2021:00:34:12 +0100] "GET /api/v1/content/articles/ HTTP/1.1" 404 65 "-" "PostmanRuntime/7.28.4"
54.86.50.139 - - [02/Dec/2021:00:33:58 +0100] "GET /api/index.php/v1/content/articles/ HTTP/1.1" 404 65 "-" "PostmanRuntime/7.28.4"
54.86.50.139 - - [01/Dec/2021:23:56:08 +0100] "POST /api/index.php/v1/content/article HTTP/1.1" 404 65 "-" "PostmanRuntime/7.28.4"
x.x.x.x - - [01/Dec/2021:23:55:40 +0100] "POST /api/index.php/v1/content/article HTTP/1.1" 406 40 "-" "Mozilla/5.0 (Windows NT; Windows NT 10.0; fr-FR) WindowsPowerShell/5.1.19041.1320"
I've checked all the system plugins are enables, CORS is enabled, but cannot find any other documentation online to troubleshoot more.
Any pointers highly appreciated.
(if any more info / details needed please don't hesitate !!)
Thanks
- toivo
- Joomla! Master
- Posts: 17352
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: Testdriving RESTful APIs - help needed
Postman seems to work all right, based on the instructions in the article how to get an API key and link it to the downloaded collection. Did you set up the Auth information and also the variable {{base_path}} as the URL of the website for the collection so that individual requests inherit it?
Toivo Talikka, Global Moderator
- aftertaf
- Joomla! Apprentice
- Posts: 14
- Joined: Sat Jan 23, 2010 1:27 pm
- Contact:
Re: Testdriving RESTful APIs - help needed
Hi, Yes i have done both.
Base URL is my https:// url without a trailing /, and the API key is set as per the video.
Base URL is my https:// url without a trailing /, and the API key is set as per the video.
- toivo
- Joomla! Master
- Posts: 17352
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: Testdriving RESTful APIs - help needed
Are you connecting to a localhost site or to a remote site? Some host configure run mod_security in their server, which may block the API, unless specific rules allow those connections.
Toivo Talikka, Global Moderator
- aftertaf
- Joomla! Apprentice
- Posts: 14
- Joined: Sat Jan 23, 2010 1:27 pm
- Contact:
Re: Testdriving RESTful APIs - help needed
Hi, this is a hosted site, remote (lws cPanel)... I've turned off mod_security to see if it helps, and it hasn't so far.
About to grab an akeeba backup to restore on a local XAMPP and test that way. I was also thinking that this is linked to the hosting somehow, otherwise the forum/bugtracker would have had way more posts on this 'not working' . ill add more info here as i get this tested. thanks!!
- aftertaf
- Joomla! Apprentice
- Posts: 14
- Joined: Sat Jan 23, 2010 1:27 pm
- Contact:
Re: Testdriving RESTful APIs - help needed
localhost/XAMPP - postman can reach & read via GET API calls.
So its my hosting that is gnarly - when i get useful info back i'll post it here in case it can help others thanks all.
So its my hosting that is gnarly - when i get useful info back i'll post it here in case it can help others thanks all.
- aftertaf
- Joomla! Apprentice
- Posts: 14
- Joined: Sat Jan 23, 2010 1:27 pm
- Contact:
Re: Testdriving RESTful APIs - help needed
My hosting provider says they've found the root cause and are in the process of correcting it. So nothing to do with J4 at all. Haven't got the explanation or the confirmation that it is fixed yet. Will post if it is helpful for others that may face this in the future . .
- aftertaf
- Joomla! Apprentice
- Posts: 14
- Joined: Sat Jan 23, 2010 1:27 pm
- Contact:
Re: Testdriving RESTful APIs - help needed
Hi (again).
So this is now working, and I've updated to J4.1.4 and have the most recent Postman API collection imported for Joomla.
I have tested and can perform some GETs & PATCHs.
I do have an issue when trying to PATCH a user though :
This is the API call : {{base_url}}/{{base_path}}/users/{{user_id}}
When i try to update any user field/property, I get the error :
"errors": [
{
"title": "The passwords you entered do not match. Please enter your desired password in the password field and confirm your entry by entering it in the confirm password field."
}
]
Status 400 Bad Request
I checked with different fields, and by 'wrapping' in "data" and "attributes" elements, as raw JSON but same error . .
Anyone had any luck at this ?
So this is now working, and I've updated to J4.1.4 and have the most recent Postman API collection imported for Joomla.
I have tested and can perform some GETs & PATCHs.
I do have an issue when trying to PATCH a user though :
This is the API call : {{base_url}}/{{base_path}}/users/{{user_id}}
When i try to update any user field/property, I get the error :
"errors": [
{
"title": "The passwords you entered do not match. Please enter your desired password in the password field and confirm your entry by entering it in the confirm password field."
}
]
Status 400 Bad Request
I checked with different fields, and by 'wrapping' in "data" and "attributes" elements, as raw JSON but same error . .
Anyone had any luck at this ?
- toivo
- Joomla! Master
- Posts: 17352
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: Testdriving RESTful APIs - help needed
Just confirmed that patching a user produces the error prompting for password and password confirmation and then saw your bug report [#37991] - [4.1.4] (and [4.2.0dev3]) - Webservices PATCH to update a user fails with status 400. We'll see what happens.
Toivo Talikka, Global Moderator
- aftertaf
- Joomla! Apprentice
- Posts: 14
- Joined: Sat Jan 23, 2010 1:27 pm
- Contact:
- aftertaf
- Joomla! Apprentice
- Posts: 14
- Joined: Sat Jan 23, 2010 1:27 pm
- Contact:
[RESOLVED] - Joomla User APIs
There's a merge request (https://github.com/joomla/joomla-cms/pull/37994) that fixes this issue. Tested on my end and works fine with the fix applied.
- toivo
- Joomla! Master
- Posts: 17352
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: Testdriving RESTful APIs - help needed
Confirmed, the fix works all right.
Toivo Talikka, Global Moderator