Re: How to submit an HTTP Request with XML

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Quoted text here. Click to load it
<snip yards of XML>
Quoted text here. Click to load it

That isn't a valid URL. At the very least all those spaces and
question-marks need escaping; also, I seriously doubt you're meant to
use a URL that long. I suspect you're meant to use POST instead of GET,
especially as a non-reversible action like uploading a file should be a
POST anyway (caches are required to pass POSTs on unmolested; this is
not true of GETs). Probably it only works from the browser by accident: the
browser 'helpfully' fixes your URL for you, and the server doesn't check
that you used the correct HTTP method.

Probably what you want is something like

    use LWP;

    my $url =  # note this *doesn't* have ?content= on the end
        " ";
    my $xml = <<XML;
<?xml version="1.0"?>

    my $UA = LWP::UserAgent->new;
    my $resp = $UA->post($url, content => $xml);

    $resp->is_success or die "POST failed: " . $resp->status_line;


Site Timeline