Trying to get a city and state from a zip5 and I can't seem to get the XML right according to the Error I keep getting "There is an Error in XML Document (2, 2)" when I run it through postman
This is the Service
private const string BaseURL = "https://secure.shippingapis.com/ShippingAPI.dll";
private WebClient wsClient = new WebClient();
public string USPS_UserID = "********";
public WebTools() { }
public WebTools(string New_UserID)
{
USPS_UserID = New_UserID;
}
private byte[] GetDataFromSite(string USPS_Request)
{
//Send the request to USPS.
byte[] ResponseData = wsClient.DownloadData(USPS_Request);
return ResponseData;
}
public byte[] CityStateLookupRequest(string ZipCode)
{
//http://production.shippingapis.com/ShippingAPITest.dll?API=CityStateLookup
// &XML=<CityStateLookupRequest USERID="xxxxxxx"><ZipCode ID= "0">
// <Zip5>90210</Zip5></ZipCode></CityStateLookupRequest>
string strResponse = "", strUSPS = "";
strUSPS = BaseURL + "?API=CityStateLookup&XML=<CityStateLookupRequest USERID=\"" + USPS_UserID + "\">";
strUSPS += "<ZipCode ID=\"0\">";
strUSPS += "<Zip5>" + ZipCode + "</Zip5>";
strUSPS += "</ZipCode></CityStateLookupRequest>";
//Send the request to USPS.
return GetDataFromSite(strUSPS);
}
}
}
I blanked out my user id