PyNamecheap icon indicating copy to clipboard operation
PyNamecheap copied to clipboard

Error - HTTP verb used to access this page is not allowed

Open moneals opened this issue 8 years ago • 8 comments

Periodically I get the following error response when checking domain availability. When I retry with the same domain it is usually successful. This is being run inside a script that executes a large volume of domain check requests sequentially.

--- Request --- https://api.namecheap.com/xml.response?UserName=xxxxxx&ApiKey=xxxxxxxxxxx&DomainList=example.com&ApiUser=xxxxxx&Command=namecheap.domain s.check&ClientIP=11.11.11.11 {} --- Response ---

405 - HTTP verb used to access this page is not allowed.

405 - HTTP verb used to access this page is not allowed.

The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.

moneals avatar Nov 22 '16 17:11 moneals

Hello!

Which version of PyNamecheap are you using? Please provide a commit hash.

It's possible that issue is about replacing URI params with POST data when large (>10) amount of items is present.

agrrh avatar Nov 23 '16 08:11 agrrh

How many domains is "large volume?". I think the API is not intended to be used as a bulk checking tool.

Bemmu avatar Nov 24 '16 06:11 Bemmu

agrrh: commit 0162105060832d118da24e916d9790af5a69466a

Bemmu: It's not really being done as a bulk checking tool. If I sequentially run through a list of a few dozen domains and check one domain at a time I regularly get the error after a few checks.

moneals avatar Dec 04 '16 23:12 moneals

@michaeos You could try then upgrade to current master or to 55a285a8f620a4730fad68bcdf0c2d49b57bacdd Both of them contain fix that could resolve the issue, if I get it right.

agrrh avatar Dec 05 '16 10:12 agrrh

I am getting the same error, when invoking namecheap.domains.getInfo for a single domain (via a subclass that I have to perform that method). So this is definitely not related to request size, but (I would guess) a sporadic error thrown by the API endpoint.

Would you like PyNamecheap to automatically retry when this error happens, or should the application do the retry?

If you would like the application to perform the retry, then I suggest throwing a better exception. Here is partial traceback, for when the error is thrown:

File "...", line 103, in domains_getInfo xml = self._call('namecheap.domains.getInfo', extra_payload) File .../PyNamecheap/namecheap.py", line 116, in _call xml = self._fetch_xml(payload, extra_payload) File ".../PyNamecheap/namecheap.py", line 105, in _fetch_xml if xml.attrib['Status'] == 'ERROR': KeyError: 'Status'

The KeyError should probably be replaced by ApiError() or some other specific exception, to make it easier for the app to detect and retry.

gstein avatar Aug 08 '17 06:08 gstein

Oh, the point to my prior comment: provide a direction, and I'll supply a patch.

gstein avatar Aug 08 '17 07:08 gstein

@gstein I suppose it's application responsibility to handle such retries.

Would you agree that retry_count and retry_delay values are too app's logic dependent? So idea to provide proper ApiError exception is a great way to solve the issue.

Here's quick and untested patch to do so, just in case you don't want to spend time: https://github.com/Bemmu/PyNamecheap/pull/14

Still looking forward to see your version which I suppose would be better.

agrrh avatar Aug 08 '17 13:08 agrrh

Well ... I could see passing those two values into the Api object (along with suitable parameter defaults), and have it perform retrying internally.

Otherwise, I would switch my Api usage code from: domains = api.domains_getList(PageSize=100) to: domains = _retry(api.domains_getList, PageSize=100)

I think that I'd prefer of the Api object retried, to keep app code cleaner. But it's your code :-) ... I'll supply either style of patch.

gstein avatar Aug 08 '17 23:08 gstein