When validating an address, I get this error:
ex = {"Error Loading XML: The following tags were not closed: AddressValidateRequest, Address, Address1.\r\n"}
or I get another error saying the address cannot be found. Is there a better way to validate this address?
Here is my URL:
http://production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=<AddressValidateRequest USERID="402JMAWE3481"><Address ID="1"><Address1>123 Main St</Address1><Address2></Address2><City>Watertown</City><State>MA</State><Zip5>02472</Zip5><Zip4></Zip4></Address></AddressValidateRequest>
According what I see on the error description, the problem could be that you need to remove. Don't forget also to url encode it.\r\n
from the xml before adding it to the urlYou actually need to HtmlEncode it and then UrlEncode it. This is becasue you're actually sending XML (which requires
&
instead of&
) but its a URL so it needs encoding to make each&
into%26
Here's a complete working URL - you just need to put in your USERID.
You'll see it contains this funky looking string:
Which I got by doing this :
[This specific error I got back when I didn't encode properly was
Error Loading XML: Whitespace is not allowed at this location
]