I'm attempting to integrate FedEx tracking services using Zeep in Python, but I'm encountering a "405 Client Error: Method Not Allowed" when I try to send a tracking request. I've been following FedEx's development guide and I've successfully used their WSDL in SoapUI. However, when I try to do the same with Zeep in my Python application, I hit this roadblock.
Here's the code snippet where the issue occurs:
from zeep import Client
from zeep.exceptions import Fault
from zeep.transports import Transport
from requests import Session
from requests.auth import HTTPBasicAuth
WSDL_URL = "https://wsbeta.fedex.com:443/web-services"
# authentication for the WSDL URL
session = Session()
session.auth = HTTPBasicAuth("USERNAME', 'PASSWORD')
transport_with_basic_auth = Transport(session=session)
# Initialize the client with the FedEx WSDL URL
client = Client(WSDL_URL, transport=transport_with_basic_auth)
web_authentication_detail = {
"UserCredential": {
"Key": "---",
"Password": "---"
}
}
client_detail = {
"AccountNumber": "---",
"MeterNumber": "----"
}
tracking_number = "557----"
# a request dictionary
request_dict = {
"WebAuthenticationDetail": web_authentication_detail,
"ClientDetail": client_detail,
"TransactionDetail": {
"CustomerTransactionId": "Test Transaction"
},
"Version": {
"ServiceId": "trck",
"Major": 20,
"Intermediate": 0,
"Minor": 0
},
"SelectionDetails": {
"CarrierCode": None,
"PackageIdentifier": {
"Type": "TRACKING_NUMBER_OR_DOORTAG",
"Value": tracking_number
}
}
}
try:
# Send the tracking request
response = client.service.track(**request_dict)
print(response)
except Fault as e:
print("Error:", e)
When I run the above code, I receive the following error:
requests.exceptions.HTTPError: 405 Client Error: Method Not Allowed for url: https://wsbeta.fedex.com:443/web-services
What I've tried so far:
Ensuring the URL is correct and accessible. Validating the WSDL with SoapUI, which works correctly. Checking that the credentials are correct.
What could be causing this issue, and how can I resolve it to successfully call the FedEx tracking service using Zeep?
Also, Please note that this is a test environment and not the live production system. I'm using test credentials and URLs as provided in the FedEx development documentation.