If you are getting a ‘statusCode‘ as “-3001″ and a ‘statusMessage‘ as “Destination Postal Code/State Name/ Country is illegal.” from the Canada Post API, it means that the city/state/country is causing problems.
At this stage, you’re obviously getting an XML response so the credentials, port, etc… should be perfectly fine.
Ensure that your XML request has the ‘city‘, ‘provOrState‘ and ‘country‘ tags in in and that those tags in the XML have values in them so that they are not empty.
In my case, I got this error trying to retrieve services/rates for a UK address and the problem occurred because I was sending “UK” in the ‘country‘ tag instead of the full country name “United Kingdom“. It is required that you use the full country names for the ‘country’ tag.
This problem was found in the development of the Canada Post API in the WordPress Shopping Cart plugin which we’re working on and caused problems on International addresses but the issue was rectified.