Sample code for 30+ languages & platforms
Perl

Bluzone Get Project Details

See more Bluzone Examples

Get a project by its id

Chilkat Perl Downloads

Perl
use strict;
use warnings;
use Chilkat2;

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

my $http = Chilkat2::Http->new;

# Implements the following CURL command:

# curl -X GET \
#   https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/ \
#   -H 'bzid: YOUR_API_KEY_HERE'

$http->SetRequestHeader('bzid', 'YOUR_API_KEY_HERE');

my $sbResponseBody = Chilkat2::StringBuilder->new;
my $success = $http->QuickGetSb('https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/', $sbResponseBody);
if (!$success) {
    print $http->LastErrorText, "\n";
    exit;
}

my $jResp = Chilkat2::JsonObject->new;
$jResp->LoadSb($sbResponseBody);
$jResp->EmitCompact(0);

print "Response Body:\n";
print $jResp->Emit(), "\n";

my $respStatusCode = $http->LastStatus;
print 'Response Status Code = ', $respStatusCode, "\n";
if ($respStatusCode >= 400) {
    print "Response Header:\n";
    print $http->LastHeader, "\n";
    print "Failed.\n";
    exit;
}

# Sample JSON response:

# {
#   "projectId": 36845,
#   "name": "My Project",
#   "description": "Default Project for admin@chilkatsoft.com, created on Thu Jun 06 17:18:11 GMT 2019.",
#   "status": null,
#   "owner": {
#     "username": "admin@chilkatsoft.com",
#     "emailAddress": null
#   },
#   "defaultUuidValue": "1b4b243c-59aa-405f-90b5-0c434cac1345",
#   "enableLocusMaps": false,
#   "mapProviderType": "GOOGLE",
#   "enableAdvancedPackets": false,
#   "enabledPacketTypes": "sBv2",
#   "enableDataUnload": false,
#   "enableScanConsumer": false,
#   "enablePolicyConsumer": false,
#   "enableLocationConsumer": false,
#   "enableEmail": true,
#   "firmwareUpdateStrategy": "MANUAL",
#   "deviceJobConcurrency": -1,
#   "mapProviderApiKey": null,
#   "wakeupUuid": null,
#   "reportEmailList": [
#   ],
#   "reportTimezone": "Etc/GMT",
#   "language": "en",
#   "blufiHostnameNaming": "DEFAULT",
#   "dateCreated": 1559841491000,
#   "dateUpdated": 1559841491000,
#   "enableStreamProducer": true,
#   "enableMetricStorage": true
# }

# Sample code for parsing the JSON response...
# Use the following online tool to generate parsing code from sample JSON:
# Generate Parsing Code from JSON

my $projectId = $jResp->IntOf('projectId');
my $name = $jResp->StringOf('name');
my $description = $jResp->StringOf('description');
my $status = $jResp->StringOf('status');
my $ownerUsername = $jResp->StringOf('owner.username');
my $ownerEmailAddress = $jResp->StringOf('owner.emailAddress');
my $defaultUuidValue = $jResp->StringOf('defaultUuidValue');
my $enableLocusMaps = $jResp->BoolOf('enableLocusMaps');
my $mapProviderType = $jResp->StringOf('mapProviderType');
my $enableAdvancedPackets = $jResp->BoolOf('enableAdvancedPackets');
my $enabledPacketTypes = $jResp->StringOf('enabledPacketTypes');
my $enableDataUnload = $jResp->BoolOf('enableDataUnload');
my $enableScanConsumer = $jResp->BoolOf('enableScanConsumer');
my $enablePolicyConsumer = $jResp->BoolOf('enablePolicyConsumer');
my $enableLocationConsumer = $jResp->BoolOf('enableLocationConsumer');
my $enableEmail = $jResp->BoolOf('enableEmail');
my $firmwareUpdateStrategy = $jResp->StringOf('firmwareUpdateStrategy');
my $deviceJobConcurrency = $jResp->IntOf('deviceJobConcurrency');
my $mapProviderApiKey = $jResp->StringOf('mapProviderApiKey');
my $wakeupUuid = $jResp->StringOf('wakeupUuid');
my $reportTimezone = $jResp->StringOf('reportTimezone');
my $language = $jResp->StringOf('language');
my $blufiHostnameNaming = $jResp->StringOf('blufiHostnameNaming');
my $dateCreated = $jResp->IntOf('dateCreated');
my $dateUpdated = $jResp->IntOf('dateUpdated');
my $enableStreamProducer = $jResp->BoolOf('enableStreamProducer');
my $enableMetricStorage = $jResp->BoolOf('enableMetricStorage');
my $i = 0;
my $count_i = $jResp->SizeOfArray('reportEmailList');
while ($i < $count_i) {
    $jResp->I($i);
    $i = $i + 1;
}