Empty response for a specific API date range

Hi All,

We are putting together a simple report web page for our users, just showing the last 3 months’ trend for Page Views and Time Spent on Page.

I’m having a problem with the following API string:
http://servernamehere/stats/piwik/index.php?module=API&method=Actions.getPageTitles&filter_pattern=ProdOps&idSite=2&period=range&date=2014-05-01,2014-05-31&format=JSON&token_auth=tokenhere

I was getting valid responses until last Thursday for May, June, and July’s API requests. Thursday morning, we started getting an empty (invalid) response for the May statistics requests. I could change the end date from May 31 to the 30th, 29th, etc. and get a valid JSON in response. Friday night, this May 1-31 range started working and giving me a valid response again.

I thought that was the end of the mystery. However, now that it’s September and the last 3 months are June, July, and August. The July 1-31 API request is getting an empty response, when it had been working fine previously. Even plugging the API request into a browser, we see an empty response. Here’s our July query:

http://servernamehere/stats/piwik/index.php?module=API&method=Actions.getPageTitles&filter_pattern=ProdOps&idSite=2&period=range&date=2014-07-01,2014-07-31&format=JSON&token_auth=tokenhere

And once again, if I change the date range even a little bit, we get a valid response.

We are on Piwik 1.12 - and we can’t upgrade just yet because another application on the server has a dependency on the older PHP version currently running. [Also - the reason we are using a date range is because period=month&date=previousn (I could be wrong about the specific syntax - I’m going from memory) doesn’t work on our version of Piwik, but I have found a report that it is fixed in a newer version. Using a date range is our workaround for now.]

Any idea what could be causing my issue with the intermittent blank response or any suggestions on what to try as a workaround?

Thank you very much,
Amy

Do you see any error in your error logs ?

Hi Matt,

With more experimentation, I’ve found that http://servernamehere/stats/piwik/index.php?module=API&method=Actions.getPageTitles&filter_pattern=ProdOps&idSite=2&period=month&date=2014-07-01&format=JSON&token_auth=tokenhere replies with a valid JSON even though specifying July’s dates with period=range is still failing. This is an acceptable workaround for us, so I’m not going to pursue further troubleshooting the range problem at this time.

As an aside, the only similarity between May’s and July’s date ranges (our intermittently failing ranges) is that they both are months with 31 days. That may not be relevant, but just wanted to make a note of it in case anyone else were to be seeing a similar problem.

Thanks!
-Amy

Maybe you can try with Piwik 2.6.1 and see if problem is fixed ?

Wish I could! But there is an app from a different team on this server that relies on an older version of PHP, so we can’t upgrade Piwik until we can upgrade PHP. We have been in negotiations about a PHP upgrade for quite a while, so I have no guess as to when this might happen.

Thanks so much,
Amy

Hi all!
I know it’s a super-old thread, but I could not find an equal newer one.
We encountered this exact same “bug” (if it is one) a few days ago, with Matomo 4.13.1
One day it stopped working, some days later it works again, changing the date one day + or - also brings the expected filled result.

Is there anything else you found out about the reason for this occuring?
If not, I’ll of course open up another, new thread on this.

Thanks in advance!

Hi Julian,

This was on Piwik and, as I remember, only had to do with months that had 31 days. I think we ended up changing our queries to work around it, but I can’t remember if we stopped using date ranges or exactly what we did.

Good luck,
Amy

Hi Amy, thanks for your fast response. :slight_smile:

This is the API query we used:
https://servername/matomo/?module=API&method=CustomDimensions.getCustomDimension&idSite=1&period=range&date=2019-06-01,2020-12-31&format=JSON&token_auth=mYtoKeN&idDimension=12

We saw that it worked on e.g. Monday, then didn’t work on Tuesday, then worked again on Wednesday, not worked on Thursday and Friday, but worked again on Saturday. Each time it did not work, changing the end-date to e.g. 2020-12-30 or 2021-01-01, it just worked like a charm again.

We also thought about a workaround, maybe I can figure out how to set such a big time span without using a range. But as ‘year’ is the biggest, and we’re trying to get data from more than one year, I cannot yet see an option to do that without range.
Else I can only think of changing the software that calls API and reads the API response, in a way that if an empty response comes back, the date range in the API call will be set to +1d, or something like that…

For further investigation, we setup a cron-job doing an API call every hour, targeting at a far-in-the-future end date, and writing the responses in a log file.

I sadly wrote transposed numbers on the Matomo Version, we are using 3.14.1
I’m afraid upgrading to 4.x could be tricky, as I read from various problems with historic data when doing that.

https://servername/matomo/?module=API&method=CustomDimensions.getCustomDimension&idSite=1&period=range&date=2019-06-01,2025-12-31&format=JSON&token_auth=mYtoKeN&idDimension=12

After a little more than 2 days, the before-working call began to deliver the same empty response we observed with the above call. Since then, the call does not work anymore, which is since a little more than 3 days now. I expect it stays like that.
If we now change the end date to 2026-01-01, it works again, delivering the expected results.

How can that even be? No log holds any error or warning message.
Is there really no way to fix this? Does nobody have a clue, what the cause may be?

We will continue to monintor the responses from both calls (2025-12-31 and 2026-01-01), to see if either the currently not working one will start to work again or the working one will stop to work in the next days (e.g. beginning of February, or whatever. Maybe we get other insights from that.

If not, I at least hope the call to +1 day does not stop to work in the future.
This could then at least be a workaround we could communicate to our customers.

Thanks in advance for any further feedback.
I’ll keep you posted!

Btw: To fix another problem with data mixed over segments in the responses, we have set “enable_segments_cache = 0” in the Matomo settings, and dropped the relevant archive tables after doing that.
But at the time of this setting-change, the empty response problem was already present.

And now this call with +1 day also stopped working. :frowning:
There goes the workaround… :unamused: