Import_logs.py -- 405 error

We are trying to import historical logs from IIS. We keep getting http error 405 (method not allowed) when running the following command:


import_logs.py --url=http://theUrl D:\LogFiles\W3SVC1\u_ex130925.log --idsite=1 --recorders=12 --enable-http-errors --enable-http-redirects --enable-static --enable-bots  --dry-run --log-format-name=iis --debug --login=######### --password=######### --token-auth=#########

The error output is:


2013-09-25 11:40:47,628: [DEBUG] Accepted hostnames: all
2013-09-25 11:40:47,634: [DEBUG] Piwik URL is: http://services.nconemap.com
2013-09-25 11:40:47,634: [DEBUG] Authentication token token_auth is: f8030584958
fba84e562bbaa4bcf204e
2013-09-25 11:40:47,634: [DEBUG] Resolver: static
2013-09-25 11:40:47,655: [DEBUG] Error when connecting to Piwik: HTTP Error 405:
 Method Not Allowed
2013-09-25 11:40:49,660: [DEBUG] Error when connecting to Piwik: HTTP Error 405:
 Method Not Allowed
2013-09-25 11:40:51,665: [DEBUG] Error when connecting to Piwik: HTTP Error 405:
 Method Not Allowed
Traceback (most recent call last):
  File "D:\piwik\misc\log-analytics\import_logs.py", line 1573, in <module>
    resolver = config.get_resolver()
  File "D:\piwik\misc\log-analytics\import_logs.py", line 529, in get_resolver
    return StaticResolver(self.options.site_id)
  File "D:\piwik\misc\log-analytics\import_logs.py", line 872, in __init__
    'SitesManager.getSiteFromId', idSite=self.site_id
  File "D:\piwik\misc\log-analytics\import_logs.py", line 854, in call_api
    return cls._call_wrapper(cls._call_api, None, None, method, **kwargs)
  File "D:\piwik\misc\log-analytics\import_logs.py", line 843, in _call_wrapper
    raise Piwik.Error(message)
__main__.Error: Method Not Allowed

All the posts we have seen indicate that it has something to do with the verbs allowed for the handler. We have changed the php handler to use “all verbs” and still get the same error. At this point we aren’t sure how to proceed. Any suggestions are greatly appreciated.

There are several reasons why this could happen.

If you are using nginx try to increase the client_max_body_size: Module ngx_http_core_module. Alternatively your firewall or webserver might block POST requests for some reason.

Thanks Fabian for responding so quickly. Our web server is IIS 7.5. We have confirmed that POST is allowed on the server and piwik applications. Do you have any other suggestions that might help us track this issue down? Thanks.

Same exact problem 2 years later and still no solution…

Maybe the problem is that your webserver doesn’t allow POST method requests?

Seeing as a am extremely new at this how do I check to see it? I have reviewed the handler mappings and “All Verbs” is checked for PHP and PHP_via_Fast_CGI. Thanks for your help on this.

Got it working! Solution: Make sure to set index.php as your default document in the IIS site you are running Piwik from.