we are currently facing a problem with authentication of out POST Requests. We cannot seem to authenticate via the token_auth parameter. We always get a “not authenticated” reply (html code of the matomo login screen).
We tried every possible authentication method.
Can someone hep us with this? We couldn’t find a solution anywhere for this. This is for a larger request we have to send via POST.
We are making the requests serverside with standard server-side POST and GET Requests.
With curl it would look something like this:
curl -d "module=API&method=API.getBulkRequest&format=json&token_auth=TOKEN&urls[0]=URLOFREQUEST" -H "Content-Type : application/json; charset=UTF-8, Content-Length: 'content length param' " -X POST "url of matomo"
But it doesn’t work with any type of POST request (url does not really matter). According to documentation, this should work as well as simple GET Requests.
Just in case anyone else, like me, ends up here from searching for solutions to this problem: Set your Content-Type to application/x-www-form-urlencoded. This is default for curl but not when using fetch() in the browser for example, which is why all the curl examples work but your code doesn’t
Thank you for this heads up, been looking for an answer for a solid 2 hours… was using application/json instead of application/x-www-form-urlencoded in my POSTMAN request and getting that pesky
You can’t access this resource as it requires a ‘superuser’ access.