API call with outlinkUrl containing an ampersand does return 0 results #19231
Labels
Bug
For errors / faults / flaws / inconsistencies etc.
c: APIs
For bugs and features in the Matomo HTTP and plugin APIs.
c: Data Integrity & Accuracy
Milestone
Expected Behavior
curl "https://www.mydomain.de/matomo/?module=API&idSite=1&format=json&token_auth=XXX&method=Actions.getOutlink&outlinkUrl=https%3A%2F%2Fwww.testdomain.de%2Ftest%2F%3Ftest%3D321%26test2%3D13&period=day&date=2022-04-26"
(and I know that this was called on the day asked) should return something like
[{"label":"/test/?test=321&test2=13","nb_visits":3,"nb_uniq_visitors":3,"nb_hits":3,"sum_time_spent":0,"url":"https://www.testdomain.de/test/?test=321&test2=13"}]%
Current Behavior
Return of
[]%
Possible Solution
Quick fix: I found that the link itself is saved as
https://www.testdomain.de/test/?test=321&test2=13
in the action database but in matomo/plugins/Actions/API.php->getFilterPageDatatableSearch the search comes as
https://www.testdomain.de/test/?test=321&test2=13 so nothing can be found.
Cause I do not know where and what exactly is en/decoded, I only added these lines directly before the last return in
protected function getFilterPageDatatableSearch($callBackParameters, $search, $actionType)
in matomo/plugins/Actions/API.php
if(isset($searchTree[1]) && strpos($searchTree[1],'&')!==false && strpos($searchTree[1],'&')===false) {
$searchTree[1]=str_replace('&','&',$searchTree[1]);
}
Now it works for me.
Your Environment
The text was updated successfully, but these errors were encountered: