只是我有一个注册 USPS它提供了 US Address Validation API
。我正在使用以下代码获取 XML 响应
。
但是,不幸的是 Response
说:
Authorization Failure User 'xxxxxxxxx' is not authorized to use 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
注意:用户 ID
是我的个人用户 ID,由 USPS 服务提供商颁发。
最佳答案
要解决此错误,我们需要调用 USPS 并通过向 USPS 发出注册 ID 来请求验证,并且首先您可以向 USPS 发送邮件作为对此问题的反馈。
关于c# - USPS 地址验证 API 中的授权失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20395069/