? No Code Attached Yet ?
avatar MayaSima
MayaSima
31 Jul 2022

Is your feature request related to a problem? Please describe.

When publishing a new article, tag or any other item via the Joomla API, if there is an existing article/tag/etc with the same alias, Joomla returns an error:

“Another article from this category has the same alias (remember it may be a trashed item).”

After that error, I need to send a PATCH request instead, but in order to do that, I need to know the id of the existing one that it collided with.

Joomla API doesn’t return the id of the existing item as part of the response, and there is no easy way to retrieve it.

Describe the solution you'd like

Ideally it should return the id of that existing item together with the error AND/OR provide an API endpoint which you can use to retrieve an existing tag/article/etc by sending its name or alias in the request body.

Additional context

avatar MayaSima MayaSima - open - 31 Jul 2022
avatar joomla-cms-bot joomla-cms-bot - change - 31 Jul 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 31 Jul 2022
avatar richard67 richard67 - change - 31 Jul 2022
Labels Added: ?
avatar richard67 richard67 - labeled - 31 Jul 2022
avatar richard67 richard67 - change - 31 Jul 2022
Labels Added: ?
avatar richard67 richard67 - labeled - 31 Jul 2022
avatar alikon
alikon - comment - 1 Aug 2022

not sure i've got you fully
anyway
simply 1st do a GET request like this:
{{base_url}}/{{base_path}}/articles/?filter[search]={{title}}
and then a POST/PATCH depending upon the GET result

avatar MayaSima
MayaSima - comment - 1 Aug 2022

I tried to filter the results using this notation, but it didn't work returning 404 error. I also did some research online and tried other options (with and without quotes around the actual text):

?attributes.title=Test.
?data.attributes.title=Test.

All of them returning 404 error.

Overall, even if I can get this filtering to work somehow, my concern is that this is going to slow down the processing significantly as search request is computationally heavy. In my project I am dealing with very large volumes of articles.

Another issue is that I do not know the alias in advance (it is generated by Joomla), and searching by title could be tricky due to special characters, low/upper case etc. Slightly different titles could result in the same alias, so it is not a very reliable type of filtering, as if the title doesn't match it is not a guarantee that the alias would not match something that already exists.

So, I think the best solution here would be to send the ID of the existing item (article, tag, menu) together with the error when a collision occurs.

avatar alikon
alikon - comment - 2 Aug 2022

it works fine from my side
image

plus there is an index on the alias field so the search cannot be so slow

avatar alikon alikon - change - 3 Aug 2022
Labels Removed: ?
avatar alikon alikon - unlabeled - 3 Aug 2022
avatar MayaSima
MayaSima - comment - 16 Aug 2022

It works indeed, not sure what I did wrong the first time I tested it. Regardless, don't you think it still would be better to send the ID of the existing item together with the error when a collision occurs?

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: ?
avatar Hackwar Hackwar - labeled - 22 Feb 2023

Add a Comment

Login with GitHub to post a comment