Monkomatic has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am trying to make an api call with xml however every time i make the call i get an error. The only workaround i could come up with was to
1) save the xml request to a text file.
2) Load the $request back in and assign to a $ string
3) then make the call.
Can anyone tell me a reason why this is happening and a method to make the call without first saving/loading the file?
# define the XML request (REVISE) if ($econfig =~ /ReviseInventoryStatusRequest/ ) { $req1 = "<?xml version='1.0' encoding='utf-8'?>" . "<ReviseInventoryStatusRequest xmlns=\"urn:ebay:apis:eBLBaseComponents +\">" . "<RequesterCredentials>". "<eBayAuthToken>$token</eBayAuthToken>". "</RequesterCredentials>". "<ErrorLanguage>en_US</ErrorLanguage>". "<WarningLevel>High</WarningLevel>". "<InventoryStatus>". "<ItemID>$uuid</ItemID>". "<StartPrice>$myprice1</StartPrice>". # "<Quantity>4</Quantity>" . "</InventoryStatus>". "</ReviseInventoryStatusRequest>"; } # POST VIA SINGLE CALL API if ($apipost == 1) {$apipost = 0 ; # WRITE THE XML REQUEST TO FILE open (UPCWRITE, '>apirequest1.txt');print UPCWRITE "$req1 stop\n";clos +e(UPCWRITE); # LOAD THE XML REQUEST BACK IN print "WOOT";print "$req1";open(F,'apirequest1.txt');@req1=<F>;close F +;$request ="@req1"; # make the call my $objRequest = HTTP::Request->new( "POST", "https://api.ebay.com/ws/api.dll", $objHeader, $request ); # deal with the response my $objUserAgent = LWP::UserAgent->new; my $objResponse = $objUserAgent->request($objRequest); if (!$objResponse->is_error) { print $objResponse->content;} else {pri +nt $objResponse->error_as_HTML;} } # if ($apipost == 1)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Formatted XML is not formatted:
by ikegami (Patriarch) on Mar 02, 2011 at 23:50 UTC | |
|
Re: Formatted XML is not formatted:
by GrandFather (Saint) on Mar 02, 2011 at 23:12 UTC |