Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Bluzone Get Project DetailsGet a project by its id For more information, see https://bluzone.io/portal/static/docs/index.html#_getprojectbyprojectid
IncludeFile "CkHttp.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i ; 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' CkHttp::ckSetRequestHeader(http,"bzid","YOUR_API_KEY_HERE") sbResponseBody.i = CkStringBuilder::ckCreate() If sbResponseBody.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkHttp::ckQuickGetSb(http,"https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/",sbResponseBody) If success = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkStringBuilder::ckDispose(sbResponseBody) ProcedureReturn EndIf jResp.i = CkJsonObject::ckCreate() If jResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoadSb(jResp,sbResponseBody) CkJsonObject::setCkEmitCompact(jResp, 0) Debug "Response Body:" Debug CkJsonObject::ckEmit(jResp) respStatusCode.i = CkHttp::ckLastStatus(http) Debug "Response Status Code = " + Str(respStatusCode) If respStatusCode >= 400 Debug "Response Header:" Debug CkHttp::ckLastHeader(http) Debug "Failed." CkHttp::ckDispose(http) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndIf ; 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 projectId.i name.s description.s status.s ownerUsername.s ownerEmailAddress.s defaultUuidValue.s enableLocusMaps.i mapProviderType.s enableAdvancedPackets.i enabledPacketTypes.s enableDataUnload.i enableScanConsumer.i enablePolicyConsumer.i enableLocationConsumer.i enableEmail.i firmwareUpdateStrategy.s deviceJobConcurrency.i mapProviderApiKey.s wakeupUuid.s reportTimezone.s language.s blufiHostnameNaming.s dateCreated.i dateUpdated.i enableStreamProducer.i enableMetricStorage.i i.i count_i.i projectId = CkJsonObject::ckIntOf(jResp,"projectId") name = CkJsonObject::ckStringOf(jResp,"name") description = CkJsonObject::ckStringOf(jResp,"description") status = CkJsonObject::ckStringOf(jResp,"status") ownerUsername = CkJsonObject::ckStringOf(jResp,"owner.username") ownerEmailAddress = CkJsonObject::ckStringOf(jResp,"owner.emailAddress") defaultUuidValue = CkJsonObject::ckStringOf(jResp,"defaultUuidValue") enableLocusMaps = CkJsonObject::ckBoolOf(jResp,"enableLocusMaps") mapProviderType = CkJsonObject::ckStringOf(jResp,"mapProviderType") enableAdvancedPackets = CkJsonObject::ckBoolOf(jResp,"enableAdvancedPackets") enabledPacketTypes = CkJsonObject::ckStringOf(jResp,"enabledPacketTypes") enableDataUnload = CkJsonObject::ckBoolOf(jResp,"enableDataUnload") enableScanConsumer = CkJsonObject::ckBoolOf(jResp,"enableScanConsumer") enablePolicyConsumer = CkJsonObject::ckBoolOf(jResp,"enablePolicyConsumer") enableLocationConsumer = CkJsonObject::ckBoolOf(jResp,"enableLocationConsumer") enableEmail = CkJsonObject::ckBoolOf(jResp,"enableEmail") firmwareUpdateStrategy = CkJsonObject::ckStringOf(jResp,"firmwareUpdateStrategy") deviceJobConcurrency = CkJsonObject::ckIntOf(jResp,"deviceJobConcurrency") mapProviderApiKey = CkJsonObject::ckStringOf(jResp,"mapProviderApiKey") wakeupUuid = CkJsonObject::ckStringOf(jResp,"wakeupUuid") reportTimezone = CkJsonObject::ckStringOf(jResp,"reportTimezone") language = CkJsonObject::ckStringOf(jResp,"language") blufiHostnameNaming = CkJsonObject::ckStringOf(jResp,"blufiHostnameNaming") dateCreated = CkJsonObject::ckIntOf(jResp,"dateCreated") dateUpdated = CkJsonObject::ckIntOf(jResp,"dateUpdated") enableStreamProducer = CkJsonObject::ckBoolOf(jResp,"enableStreamProducer") enableMetricStorage = CkJsonObject::ckBoolOf(jResp,"enableMetricStorage") i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"reportEmailList") While i < count_i CkJsonObject::setCkI(jResp, i) i = i + 1 Wend CkHttp::ckDispose(http) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.