PyNamecheap
PyNamecheap copied to clipboard
Error - HTTP verb used to access this page is not allowed
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 ---
Server Error
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.
How many domains is "large volume?". I think the API is not intended to be used as a bulk checking tool.
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.
@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.
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.
Oh, the point to my prior comment: provide a direction, and I'll supply a patch.
@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.
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.