🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #226

IdHTTP Get with XML

#226
From: Stephen
Date: Mon, 30 Jul 2007 15:19
40 lines
2146 bytes
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
Technical Details
Message-ID: <46ae0187$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,e5404376e6a3e175,start
X-Google-Attributes: gidfeeec,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Stephen" <susreyNOSPAM.excite.com>
Newsgroups: borland.public.cppbuilder.internet.web
Subject: IdHTTP Get with XML
Date: Mon, 30 Jul 2007 10:19:35 -0500
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.3959
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4073
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 72.16.12.137
Message-ID: <46ae0187$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1185808775 72.16.12.137 (30 Jul 2007 08:19:35 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail