? Pending

User tests: Successful: Unsuccessful:

avatar alexandreelise
alexandreelise
18 Mar 2020

Pull Request for Issue # .

Summary of Changes

A quick fix to allow joomla 4 webservices to work and not returning 404 resource not found.
I just removed an ! to invert the logic. To me it seemed like a typo. But before finding this I had to debug using Postman and PhpStorm.
With this fix: it returns list of articles as expected.
@wilsonge I debugged it really deep using PhpStorm. Tell me what you think if it works for you too. Hope it helps.

Testing Instructions

Try to access the article webservice using curl or Postman
GET /api/index.php/v1/content/article

Expected result

GET /api/index.php/v1/content/article should return a list of articles json-api response.

Actual result

GET /api/index.php/v1/content/article returns Resource not found json response.

Documentation Changes Required

no

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar alexandreelise alexandreelise - change - 18 Mar 2020
Status New Pending
avatar alexandreelise alexandreelise - open - 18 Mar 2020
avatar joomla-cms-bot joomla-cms-bot - change - 18 Mar 2020
Category Libraries
avatar alexandreelise alexandreelise - change - 18 Mar 2020
The description was changed
avatar alexandreelise alexandreelise - edited - 18 Mar 2020
avatar alexandreelise
alexandreelise - comment - 19 Mar 2020

I launched the api-tests locally using what is provided in the official 4.0-dev branch and it was successful even with a non-standard port for https. Not sure why drone-ci is complaining for api-tests.

avatar richard67
richard67 - comment - 19 Mar 2020

@alexandreelise You can see the drone log files when following the "Details" link right beside the drone result. Then you can see at the left hand side a list of tests, coloured in red if failed, and when selecting such a failed test, you san see on the right hand side the corresponding log.

The PHP 8 unit tests currently fail, this is known and allowed, but in case of your PR the API test failed, too, and when reading the log file it seems to me that it fails when testing for access with bad credentials: It expects to get a 404 response but gets a 401, as far as I understand it. And this could be indeed related to your PR.

@Hackwar @wilsonge Does one of you know the API router well enoguh to tell if the change in this PR is correct or not?

avatar alikon
alikon - comment - 19 Mar 2020

i cannot replicate the issue or better
can you give more detailed info on when this happens please

avatar alexandreelise
alexandreelise - comment - 19 Mar 2020

Hello everyone. I performed the same tests locally with the same tests suite for api tests and all passed fine. Moreover the correct http header for invalid credential is 401 unauthorised not 404 not found. maybe there is some kind of error in this api test regarding the bad credential. Thanks for your time and patience.

avatar Quy
Quy - comment - 19 Mar 2020

@wilsonge When Use URL Rewriting is enabled, would the URL be the same /api/index.php/v1/article? I tried /api/v1/article, I tried /v1/article, but no go.

avatar Quy
Quy - comment - 20 Mar 2020

@alikon Enable Use URL Rewriting to reproduce this issue. However, I don't this PR is the right fix.

avatar wilsonge
wilsonge - comment - 20 Mar 2020

We'd expect it to strip index.php when the setting is enabled (combined with a htaccess/nginx change server side like we require when enabling this setting in the frontend)

avatar Razzo1987
Razzo1987 - comment - 9 Apr 2020

I have tested this item ? unsuccessfully on fe92726

I have:

  • Applied the patch
  • Enabled Use URL Rewriting in Global Configuration
  • Renamed htaccess.txt to .htaccess

If I do a GET call to {{base_path}}/api/v1/content/article it returns 404 Not Found


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28394.
avatar Razzo1987 Razzo1987 - test_item - 9 Apr 2020 - Tested unsuccessfully
avatar alexandreelise
alexandreelise - comment - 9 Apr 2020

Maybe I didn't have the same version of the code as anyone in this discussion has. I will retry on nightlies of Joomla 4.x and I'll give you all some feedback.If it still won't work, hopefully someone will fix the problem. If there is no apparent problem. Just let it be. Take care. Have a great day. Thanks for your time and patience.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28394.

avatar infograf768 infograf768 - change - 9 Apr 2020
Title
Update ApiRouter.php
[4.0] Update ApiRouter.php
avatar infograf768 infograf768 - edited - 9 Apr 2020
avatar toivo
toivo - comment - 24 May 2020

@alexandreelise @infograf768 @SharkyKZ Tested #28394 in connection with #29020 and indeed it allows the API to work when 'Use URL Rewriting' has been selected in Global Configuration. However, if 'Use URL Rewriting' has not been selected, we get 404 - Resource not found.

IMHO, we cannot require websites that expose web services to be consumed by their systems to use 'Use URL Rewriting', even though that would make sense. Is there a simple solution where both modes can be supported?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28394.

avatar Quy
Quy - comment - 24 May 2020

This is not the correct fix. See #26564 (comment) for the proposed solution.

avatar Quy Quy - close - 24 May 2020
avatar Quy Quy - change - 24 May 2020
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2020-05-24 15:33:27
Closed_By Quy
Labels Added: ?
avatar SharkyKZ
SharkyKZ - comment - 24 May 2020

This looks correct on code review, going to re-open this for now. But we still need .htaccess for API.

avatar SharkyKZ SharkyKZ - change - 24 May 2020
Status Closed New
Closed_Date 2020-05-24 15:33:27
Closed_By Quy
avatar SharkyKZ SharkyKZ - change - 24 May 2020
Status New Pending
avatar SharkyKZ SharkyKZ - reopen - 24 May 2020
avatar SharkyKZ
SharkyKZ - comment - 24 May 2020

Should both versions, with and without index.php, work regardless of rewrite setting? Like it does in site app? If so, the check can be removed and index.php should always be stripped out because regexps never include it.

avatar wilsonge
wilsonge - comment - 24 May 2020

Behaviour should be the same as the site apps. But we don't have the magic router for the build function - unsure quite how that impacts us honestly https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Router/SiteRouter.php#L550-L576

avatar SharkyKZ
SharkyKZ - comment - 25 May 2020

In that case the option check can be removed and index.php always stripped.

But we don't have the magic router for the build function - unsure quite how that impacts us honestly

URLs are built based on current URL. I.e. if current URL has index.php, all URLs built also going to have it, regardless of rewrite option. Is this intended behavior?

avatar wilsonge
wilsonge - comment - 31 May 2020

@alexandreelise can you please test #29303 I think this should be the correct fix for the issues you have experienced

avatar Quy
Quy - comment - 31 May 2020

Fixed #29303

avatar Quy Quy - close - 31 May 2020
avatar Quy Quy - change - 31 May 2020
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2020-05-31 19:31:03
Closed_By Quy
avatar alexandreelise
alexandreelise - comment - 31 May 2020

Thanks @nikosdion for addressing the issue and solve it. Didn't try yet but hopefully it should work as for everybody else. Take care everybody. Joomla 4 is closer and closer. Official Beta 1 out today. Woohoo! It will help me for my webservice presentation june 12 2020.

Add a Comment

Login with GitHub to post a comment