New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API method SitesManager.getSitesIdFromSiteUrl doesn't return a Site ID #9901
Comments
Here is an example of this issue (excuse the Let's Encrypt staging cert), this site: Is using Piwik running at https://piwik.wsh.webarchitects.org.uk/ and has the site id 44 but this API URL Returns: <?xml version="1.0" encoding="utf-8" ?>
<result /> When I'd expect the result to be: <?xml version="1.0" encoding="utf-8" ?>
<result>
<row>
<idsite>44</idsite>
</row>
</result> As illustrated here: What am I doing wrong? Or is there a problem with Piwik? The System Check reports:
However after enabling that in |
I had a look at the code and only thing I could think of, that for some reason your URL maybe has a trailing slash saved in the database? I noticed when adding a site url, adding a site or updating a site, we do remove all trailing slashes from all urls. In the API method That's just a random guess as the URL should not be saved with a trailing slash. Another idea would be that the auth token you are using does not have at least view access for that website.
|
Maybe check in the UI or database ( |
No trailing slash in the database:
But perhaps this is the issue, there is no matching row in the
The auth token I was using is the admin one and it doesn't have a problem creating users or adding sites. |
It doesn't have to have an entry in Your |
Yes, sorry, that was my mistake, they were separated with |
Maybe try |
I tried like this:
But that doesn't return a Site ID, and doesn't result in a site being added to Piwik, have I made a mistake in the formatting of the URL? |
This seems to work OK (URL encoding carriage returns):
I'll do some more testing and when I'm confident that it is all OK I'll close this issue, thanks for all the help. |
You had |
Oops I spoke too soon, using
|
That did the trick! Sorry for my stupid mistake, using this URL:
The sites get added correctly:
Thanks again for your patience :-) PS Perhaps adding an example for SitesManager.addSite here: https://developer.piwik.org/api-reference/reporting-api#SitesManager would prevent people like me having problems like this in the future... |
I just added an example. I'm glad we could fix it. Thx for helping to make our docs better 👍 |
With Piwik 2.16.0 the only result I get from a URL like this:
is:
Can anyone confirm that this API method works? I'm I doing something stupid?
The text was updated successfully, but these errors were encountered: