AnsweredAssumed Answered

API call asset_group.php return HTTP Error 414

Question asked by alex setiadi on Oct 10, 2013
Latest reply on Oct 14, 2013 by Parag Baxi

Hi,

 

I'm writing a script using perl, I'm utilizing the LWP::useragent to make the API call. The script works if I have a smaller amount of IP addressses, however, I'm stuck where I need to add 4000+ IP addresses in which they are all in different subnets and range.

Are there any way to do this ?

The only way I can think of right now, is to break down the IP list, so I can have shorter URI length and do multiple API call. But I'm wondering if anyone else able to do it in 1 API call.

 

my $url = "https://qualysapi.vscan.apple.com/msp/asset_ip.php?action=add&title=$title&host_ips=$ips";

 

my $ua  = LWP::UserAgent->new();

 

my $request =  HTTP::Request->new(GET => $url);

 

print "\nREQUEST: ", $request->as_string ,"\n";

 

$request->authorization_basic($user, $pwd);

 

my $result = $ua->request($request);

 

if ($result->is_success) {

          print STDERR "\nSUCCESS: " , $result->content;

 

} else {

# An HTTP related error

          printf STDERR "\nFAIL: HTTP Error: %s\n", $result->as_string;

exit 1;

}

 

 

Here's the output:

 

Request:

GET https://qualysapi.vscan.apple.com/msp/asset_ip.php?action=add&title=test&host_ips=[4000+IPaddress]

 

Response:

HTTP/1.1 414 Request-URI Too Large

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<HTML><HEAD>

<TITLE>414 Request-URI Too Large</TITLE>

</HEAD><BODY>

<H1>Request-URI Too Large</H1>

The requested URL's length exceeds the capacity

limit for this server.<P>

request failed: URI too long<P>

</BODY></HTML>

Outcomes