WAS THIS PAGE HELPFUL? Leave Feedback
5.0 APPENDIX E Perl Examples
Appendix E: Contents
5.1 Query Services
#!/usr/bin/perl use REST::Client; use MIME::Base64; use JSON; #The basic use case my $client = REST::Client->new(); $client->addHeader("Authorization", "Basic " . encode_base64("wsuser:wsuser")); $client->addHeader("Accept", "application/json"); # $client->addHeader("Accept", "application/xml"); my $queryData = { 'query' => 'lastCheckTime is not null and appType = \'VEMA\' order by lastCheckTime', 'count' => '1' }; my $params = $client->buildQuery( $queryData ); $client->GET('http://localhost/api/services' . $params); my $response = decode_json($client->responseContent()); print $client->responseContent() . "\n"; my $service = $response->{'services'}->[0]; print "lastPlugInOutput: $service->{'lastPlugInOutput'}\n"; print "LastPluginOutput: $service->{'properties'}->{'LastPluginOutput'}\n";