🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: IdHTTP Get with XML

#228
From: Remy Lebeau (TeamB)
Date: Mon, 30 Jul 2007 17:10
50 lines
2263 bytes
"Stephen" <susreyNOSPAM.excite.com> wrote in message
news:46ae0187$1@newsgroups.borland.com...

> when I attempt to programatically get the data, I fail.

That is because you are not sending the request correctly, as the server is
telling you.

> My URL is (user ID changed):
<snip>

You should be encoding that URL before passing it to Get().

> My code is:
>
>   AnsiString  sString = "?API=Verify&XML=<?xml
<snip>

You are not including the full URL address in that string, only the query
portion.  You must provide the full URL.

>    http->Request->ContentType = "text/xml";

You are sending the XML through the URL itself, not through a post stream,
so the ContentType is meaningless in this case.


Try this instead:

    AnsiString  sString =
"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><Zip
4></Zip4></Address></AddressValidateRequest>";

    sString = TIdURI::URLEncode(__classid(TIdURI), sString);

    TIdHTTP* http = new TIdHTTP(NULL);
    try
    {
        ShowMessage(http->Get(sString));
    }
    __finally {
        delete http;
    }


Gambit
Technical Details
Message-ID: <46ae1bca$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46ae0187$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,e5404376e6a3e175
X-Google-Attributes: gidfeeec,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.web
References: <46ae0187$1@newsgroups.borland.com>
Subject: Re: IdHTTP Get with XML
Date: Mon, 30 Jul 2007 10:10:52 -0700
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.82.252.126
Message-ID: <46ae1bca$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1185815498 75.82.252.126 (30 Jul 2007 10:11:38 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail