Issues with Piwik bulk tracking API

I’ve been testing using Piwik with the tracking API to work around custom data that I receive offline and need to process for further use. It has been fine while doing separate calls for each request, but I’m wondering if the intended use for bulk tracking is completely different from what I’m doing.

For each request I have a number of variables including cdt and cip which require token_auth. As per the instructions on the site I wrapped 5 requests into one “batch” and included token_auth as a separate parameter (it was also included in each query string in the batch). This resulted in nothing being added to the DB and also warnings that CDT requires token_auth.

DEBUG Piwik\Common[2016-11-01 13:22:37] [a8755] Custom timestamp is 2717878 seconds old, requires &token_auth…
DEBUG Piwik\Common[2016-11-01 13:22:37] [a8755] WARN: Tracker API ‘cdt’ was used with invalid token_auth

So I modified it so that token_auth is only set in the JSON request and not in the individual calls, but after this I receive HTTP status 400 for each request with quite a lot of errors:

DEBUG Piwik\Common[2016-11-01 13:22:37] [a8755] array (
DEBUG Piwik\Common[2016-11-01 13:22:37] [a8755] ‘{“requests”:_"idsite’ => ‘10’,

DEBUG CoreHome[2016-11-01 13:22:37] [a8755] WARN: Tracker API ‘cip’ was used with invalid token_auth

DEBUG Piwik\Common[2016-11-01 13:22:37] [a8755] Exception: Invalid idSite: ‘0’

So apart from still not allowing variables that require token_auth, it seem’s to be confused about what site the request was for (even though it managed to parse it earlier).

Is there something I’m not getting? One notice, I’m using GET requests rather then POST, but it seems to be at least getting the payload and managing to handle each row individually just not liking the data it see’s…

How long is the GET string. From memory GET strings can be a maximum of 256 characters. Are you going over this? If so, you’ll have to use POST which, i believe, is limited to 64K.

Thanks for the reply!

The querystring seems to be close to 3000 characters and actually a single non-batched request is already over 550. Based on a quick read it seems there is no limit in the RFC, rather depends on implementation. There is also a response code that should indicate it’s over the limit (though I don’t know how well that would work). And finally most issues seem to come from browsers rather then the server.

I could test with POST request to close that out though.

edit:

Got it to work, my query strings where missing the ‘?’ character inside the batch