Sample code for 30+ languages & platforms
Java

Bluzone Get Project Details

See more Bluzone Examples

Get a project by its id

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.JsonObject;
import com.chilkatsoft.chilkat2.StringBuilder;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Http http = new Http();

        // 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");

        StringBuilder sbResponseBody = new StringBuilder();
        try {
            http.quickGetSb("https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/", sbResponseBody);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        JsonObject jResp = new JsonObject();
        jResp.loadSb(sbResponseBody);
        jResp.setEmitCompact(false);

        System.out.println("Response Body:");
        System.out.println(jResp.emit());

        int respStatusCode = http.getLastStatus();
        System.out.println("Response Status Code = " + respStatusCode);
        if (respStatusCode >= 400) {
            System.out.println("Response Header:");
            System.out.println(http.getLastHeader());
            System.out.println("Failed.");
            return;
        }

        // 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

        int projectId = jResp.intOf("projectId");
        String name = jResp.stringOf("name");
        String description = jResp.stringOf("description");
        String status = jResp.stringOf("status");
        String ownerUsername = jResp.stringOf("owner.username");
        String ownerEmailAddress = jResp.stringOf("owner.emailAddress");
        String defaultUuidValue = jResp.stringOf("defaultUuidValue");
        boolean enableLocusMaps = jResp.boolOf("enableLocusMaps");
        String mapProviderType = jResp.stringOf("mapProviderType");
        boolean enableAdvancedPackets = jResp.boolOf("enableAdvancedPackets");
        String enabledPacketTypes = jResp.stringOf("enabledPacketTypes");
        boolean enableDataUnload = jResp.boolOf("enableDataUnload");
        boolean enableScanConsumer = jResp.boolOf("enableScanConsumer");
        boolean enablePolicyConsumer = jResp.boolOf("enablePolicyConsumer");
        boolean enableLocationConsumer = jResp.boolOf("enableLocationConsumer");
        boolean enableEmail = jResp.boolOf("enableEmail");
        String firmwareUpdateStrategy = jResp.stringOf("firmwareUpdateStrategy");
        int deviceJobConcurrency = jResp.intOf("deviceJobConcurrency");
        String mapProviderApiKey = jResp.stringOf("mapProviderApiKey");
        String wakeupUuid = jResp.stringOf("wakeupUuid");
        String reportTimezone = jResp.stringOf("reportTimezone");
        String language = jResp.stringOf("language");
        String blufiHostnameNaming = jResp.stringOf("blufiHostnameNaming");
        int dateCreated = jResp.intOf("dateCreated");
        int dateUpdated = jResp.intOf("dateUpdated");
        boolean enableStreamProducer = jResp.boolOf("enableStreamProducer");
        boolean enableMetricStorage = jResp.boolOf("enableMetricStorage");
        int i = 0;
        int count_i = jResp.sizeOfArray("reportEmailList");
        while (i < count_i) {
            jResp.setI(i);
            i = i + 1;
        }
    }
}