Trouble with Piwik API URL

Posted this on Stackoverflow and then realised here would be more appropriate.

I’m trying to make an application to get data from the Piwik API to
process and analyse. I’m having trouble getting the API URL to work
properly for our specific site (our Piwik is a multi-site installation,
our site is identified by a segment variable, specifically
customVariableValue1=9).

(I’ve replaced our domain and token with placeholders)
This URL works fine:
https://example.com/piwik/?module=API&method=Actions.getPageUrls&idSite=3&date=yesterday&period=day&format=json&token_auth=mytoken

However when I try to access this:
https://example.com/piwik/?module=API&method=Actions.getPageUrls&idSite=3&date=yesterday&period=day&%20segment=customVariableValue1%3D%3D9#&format=json&token_auth=mytoken

I get this error: <error message="You can't access this resource as it requires an 'view' access for the website id = 3."/> back. The token I am using is definitely correct so I have no idea why it’s coming back with that error.

Any help would be greatly appreciated! :slight_smile:

I think it is your id site which is not the good one. Check it.

Hi @mimzo,

did you find any way to get around this problem? I got the same one, and don’t have a clue what is going wrong.

Thank you a lot!
Carsten

Hey, thanks for the reply! As far as I know the id site is fine, that’s the one we use to view the data that I’m trying to get. The problem happens when I add the segment in. How am I supposed to find the correct idsite etc for the api url to use?

HI @Billy,

in my case, the problem in my code was the action: “index” in actionToWidgetize. Changing the action to “get” solved the problem.

Seems that not every valid embed in Piwik 2 is valid in Piwik 3. So you should generate new Codes for your widgets, i think.

That worked for me.

Have a nice day!
Carsten

To see your id site, you mus go to administration icone, and you click on “sites web” on your left

I’m pretty sure the SiteId is NOT the problem. The error message is the same, when getting a non-supported Embed-Type.

Try getting new Embed-Codes. It worked for me.