本文介绍了在USPS地址验证API授权失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只有我已注册,提供美国地址验证API
。我使用下面的代码来获取 XML响应
。
但不幸的是,回应
说:
我缺少一些东西?
代码:
void IsValidAddress b $ b {
string USPS =http://production.shippingapis.com/ShippingAPITest.dll?API=Verify&XML=<AddressValidateRequest%20USERID='xxxxxxx'> ;<Address ID ='1 '>< / Address>< / 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(responseData中的字节项)
{
//这将返回xml响应
response + =(char)item;
}
string result = response;
Response.Write(result);
}
请参阅:
请注意:用户ID
是USPS服务提供商发行的我的个人用户ID。
Just i have a Registered with USPS which provides the US Address Validation API
. I am using the following code to get the XML Response
.
But, unfortunately the Response
says:
Do i missing something?
Code:
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);
}
Please see: How to Validate Address on USPS
Note: the User ID
is my personal User ID that is issued by USPS Service Provider.
解决方案
To Resolve this error we need to call the USPS and ask for Verification by issuing the Registered ID with USPS and also first you can send Mail to USPS as a Feedback for this issue.
这篇关于在USPS地址验证API授权失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!