Sample code for 30+ languages & platforms
SQL Server

Bluzone Get Project Details

See more Bluzone Examples

Get a project by its id

Chilkat SQL Server Downloads

SQL Server
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

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

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

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

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'bzid', 'YOUR_API_KEY_HERE'

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END

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

    DECLARE @projectId int

    DECLARE @name nvarchar(4000)

    DECLARE @description nvarchar(4000)

    DECLARE @status nvarchar(4000)

    DECLARE @ownerUsername nvarchar(4000)

    DECLARE @ownerEmailAddress nvarchar(4000)

    DECLARE @defaultUuidValue nvarchar(4000)

    DECLARE @enableLocusMaps int

    DECLARE @mapProviderType nvarchar(4000)

    DECLARE @enableAdvancedPackets int

    DECLARE @enabledPacketTypes nvarchar(4000)

    DECLARE @enableDataUnload int

    DECLARE @enableScanConsumer int

    DECLARE @enablePolicyConsumer int

    DECLARE @enableLocationConsumer int

    DECLARE @enableEmail int

    DECLARE @firmwareUpdateStrategy nvarchar(4000)

    DECLARE @deviceJobConcurrency int

    DECLARE @mapProviderApiKey nvarchar(4000)

    DECLARE @wakeupUuid nvarchar(4000)

    DECLARE @reportTimezone nvarchar(4000)

    DECLARE @language nvarchar(4000)

    DECLARE @blufiHostnameNaming nvarchar(4000)

    DECLARE @dateCreated int

    DECLARE @dateUpdated int

    DECLARE @enableStreamProducer int

    DECLARE @enableMetricStorage int

    DECLARE @i int

    DECLARE @count_i int

    EXEC sp_OAMethod @jResp, 'IntOf', @projectId OUT, 'projectId'
    EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'name'
    EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'description'
    EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'status'
    EXEC sp_OAMethod @jResp, 'StringOf', @ownerUsername OUT, 'owner.username'
    EXEC sp_OAMethod @jResp, 'StringOf', @ownerEmailAddress OUT, 'owner.emailAddress'
    EXEC sp_OAMethod @jResp, 'StringOf', @defaultUuidValue OUT, 'defaultUuidValue'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enableLocusMaps OUT, 'enableLocusMaps'
    EXEC sp_OAMethod @jResp, 'StringOf', @mapProviderType OUT, 'mapProviderType'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enableAdvancedPackets OUT, 'enableAdvancedPackets'
    EXEC sp_OAMethod @jResp, 'StringOf', @enabledPacketTypes OUT, 'enabledPacketTypes'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enableDataUnload OUT, 'enableDataUnload'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enableScanConsumer OUT, 'enableScanConsumer'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enablePolicyConsumer OUT, 'enablePolicyConsumer'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enableLocationConsumer OUT, 'enableLocationConsumer'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enableEmail OUT, 'enableEmail'
    EXEC sp_OAMethod @jResp, 'StringOf', @firmwareUpdateStrategy OUT, 'firmwareUpdateStrategy'
    EXEC sp_OAMethod @jResp, 'IntOf', @deviceJobConcurrency OUT, 'deviceJobConcurrency'
    EXEC sp_OAMethod @jResp, 'StringOf', @mapProviderApiKey OUT, 'mapProviderApiKey'
    EXEC sp_OAMethod @jResp, 'StringOf', @wakeupUuid OUT, 'wakeupUuid'
    EXEC sp_OAMethod @jResp, 'StringOf', @reportTimezone OUT, 'reportTimezone'
    EXEC sp_OAMethod @jResp, 'StringOf', @language OUT, 'language'
    EXEC sp_OAMethod @jResp, 'StringOf', @blufiHostnameNaming OUT, 'blufiHostnameNaming'
    EXEC sp_OAMethod @jResp, 'IntOf', @dateCreated OUT, 'dateCreated'
    EXEC sp_OAMethod @jResp, 'IntOf', @dateUpdated OUT, 'dateUpdated'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enableStreamProducer OUT, 'enableStreamProducer'
    EXEC sp_OAMethod @jResp, 'BoolOf', @enableMetricStorage OUT, 'enableMetricStorage'
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'reportEmailList'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO