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.
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.
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
?
|
Labels |
Added:
?
|
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.
Labels |
Removed:
?
|
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?
Labels |
Added:
?
|
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