我刚注册了USPS,提供了US Address Validation API
。我使用以下代码获取XML Response
。
但是,遗憾的是Response
说:
授权失败用户'xxxxxxxxx'无权使用API Verify.USPSCOM :: DoAuth。
我错过了什么吗?
代码:
void IsValidAddress()
{
string USPS = "http://production.shippingapis.com/ShippingAPITest.dll?API=Verify&XML=<AddressValidateRequest%20USERID='xxxxxxx'><Address ID='1'><Address1></Address1><Address2>8 Wildwood Drive</Address2><City>Old Lyme</City><State>CT</State><Zip5>06371</Zip5><Zip4></Zip4></Address></AddressValidateRequest>";
WebClient wsClient = new WebClient();
byte[] responseData = wsClient.DownloadData(USPS);
string response = string.Empty;
foreach (byte item in responseData)
{
//this will return the xml response
response += (char)item;
}
string result = response;
Response.Write(result);
}
请参阅:How to Validate Address on USPS
注意: User ID
是我的个人用户ID,由USPS服务提供商发布。
答案 0 :(得分:3)
要解决此错误,我们需要通过向USPS发出注册ID来呼叫USPS并要求进行验证,并且首先您可以将邮件发送到USPS作为此问题的反馈。