Stephen
2007-07-30 15:19:35 UTC
I'm attempting to validate addresses and zipcode through the post office's
server.
When I cut and copy the complete url to my web browser, I get a sucessful
verification, but when I attempt to programatically get the data, I fail.
Any pointers and example code would be greatly appreciated it, I'm really
new to this.
The result of my test is "400 Bad request".
My URL is (user ID changed):
http://testing.shippingapis.com/ShippingAPITest.dll?API=Verify&XML=<?xml
version='1.0'?><AddressValidateRequest USERID='999xxxxx9999'><Address
ID='0'><Address1></Address1><Address2>6406 Ivy
Lane</Address2><City>Greenbelt</City><State>md</State><Zip5>74429</Zip5><Zip4></Zip4></Address></AddressValidateRequest>
My code is:
AnsiString sString = "?API=Verify&XML=<?xml
version='1.0'?><AddressValidateRequest USERID='999xxxxx9999'><Address
ID='0'><Address1></Address1><Address2>6406 Ivy
Lane</Address2><City>Greenbelt</City><State>md</State><Zip5>74429</Zip5><Zip4></Zip4></Address></AddressValidateRequest>";
TIdHTTP* http = new TIdHTTP(Application);
http->Request->ContentType = "text/xml";
TStringStream* outstr = new TStringStream("");
try {
http->Get(sString, outstr);
ShowMessage(outstr->DataString);
}
__finally {
delete outstr;
}
Thank you for any pointers / help
server.
When I cut and copy the complete url to my web browser, I get a sucessful
verification, but when I attempt to programatically get the data, I fail.
Any pointers and example code would be greatly appreciated it, I'm really
new to this.
The result of my test is "400 Bad request".
My URL is (user ID changed):
http://testing.shippingapis.com/ShippingAPITest.dll?API=Verify&XML=<?xml
version='1.0'?><AddressValidateRequest USERID='999xxxxx9999'><Address
ID='0'><Address1></Address1><Address2>6406 Ivy
Lane</Address2><City>Greenbelt</City><State>md</State><Zip5>74429</Zip5><Zip4></Zip4></Address></AddressValidateRequest>
My code is:
AnsiString sString = "?API=Verify&XML=<?xml
version='1.0'?><AddressValidateRequest USERID='999xxxxx9999'><Address
ID='0'><Address1></Address1><Address2>6406 Ivy
Lane</Address2><City>Greenbelt</City><State>md</State><Zip5>74429</Zip5><Zip4></Zip4></Address></AddressValidateRequest>";
TIdHTTP* http = new TIdHTTP(Application);
http->Request->ContentType = "text/xml";
TStringStream* outstr = new TStringStream("");
try {
http->Get(sString, outstr);
ShowMessage(outstr->DataString);
}
__finally {
delete outstr;
}
Thank you for any pointers / help