Getting HTTP Error 405: Method Not Allowed

Hi,
I’m trying to request airline info and getting HTTP Error 405: Method Not Allowed exception.
My python code as follows:

#!/usr/bin/env python3

import sys
from suds import null, WebFault
from suds.client import Client
import logging

wsdlFile = 'http://flightxml.flightaware.com/soap/FlightXML2/wsdl'
api = Client(wsdlFile, username=username, password=apiKey)
airline_info = api.service.AirlineInfo('AFL')
print(airline_info)

Error I'm getting:

ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://flightxml.flightaware.com/soap/FlightXML2" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:AirlineInfoRequest>
         <ns0:airlineCode>AFL</ns0:airlineCode>
      </ns0:AirlineInfoRequest>
   </ns1:Body>
</SOAP-ENV:Envelope>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/suds/transport/http.py", line 78, in send
    fp = self.u2open(u2request)
  File "/usr/local/lib/python3.7/site-packages/suds/transport/http.py", line 119, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 405: Method Not Allowed

Could some one help me with this issue?

It looks like this error may be specific to the suds-py3 package. Using the more up-to-date suds-jurko package instead allows for requests to work properly without any other code changes to your example.

1 Like

Great, works!
Saved me some hours of desperate code debugging, thanks.