Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual FoxPro Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(Visual FoxPro) Azure Create Storage Account

Demonstrates how to create an Azure storage account.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loHttp
LOCAL loJsonToken
LOCAL lnSuccess
LOCAL loJsonRequestBody
LOCAL lcUrl
LOCAL loResp
LOCAL loJson
LOCAL lcSkuName
LOCAL lcSkuTier
LOCAL lcKind
LOCAL lcId
LOCAL lcName
LOCAL lcV_type
LOCAL lcLocation
LOCAL lcPropertiesNetworkAclsBypass
LOCAL lcPropertiesNetworkAclsDefaultAction
LOCAL lnPropertiesSupportsHttpsTrafficOnly
LOCAL lnPropertiesEncryptionServicesFileEnabled
LOCAL lcPropertiesEncryptionServicesFileLastEnabledTime
LOCAL lnPropertiesEncryptionServicesBlobEnabled
LOCAL lcPropertiesEncryptionServicesBlobLastEnabledTime
LOCAL lcPropertiesEncryptionKeySource
LOCAL lcPropertiesAccessTier
LOCAL lcPropertiesProvisioningState
LOCAL lcPropertiesCreationTime
LOCAL lcPropertiesPrimaryEndpointsDfs
LOCAL lcPropertiesPrimaryEndpointsWeb
LOCAL lcPropertiesPrimaryEndpointsBlob
LOCAL lcPropertiesPrimaryEndpointsQueue
LOCAL lcPropertiesPrimaryEndpointsTable
LOCAL lcPropertiesPrimaryEndpointsFile
LOCAL lcPropertiesPrimaryLocation
LOCAL lcPropertiesStatusOfPrimary
LOCAL lcPropertiesSecondaryLocation
LOCAL lcPropertiesStatusOfSecondary
LOCAL i
LOCAL lnCount_i

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

* Load an OAuth2 access token previously fetched by this example:  Get Azure OAuth2 Access Token
loJsonToken = CreateObject('Chilkat_9_5_0.JsonObject')
lnSuccess = loJsonToken.LoadFile("qa_data/tokens/azureToken.json")
* Assuming success..
loHttp.AuthToken = loJsonToken.StringOf("access_token")
? "AuthToken: " + loHttp.AuthToken

loHttp.Accept = "application/json"

* Create the following JSON:

* {
*   "sku": {
*     "name": "Standard_GRS"
*   },
*   "kind": "StorageV2",
*   "location": "eastus2",
* }

* Use this online tool to generate the code from sample JSON: 
* Generate Code to Create JSON

loJsonRequestBody = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonRequestBody.UpdateString("sku.name","Standard_GRS")
loJsonRequestBody.UpdateString("kind","StorageV2")
loJsonRequestBody.UpdateString("location","eastus2")

lcUrl = "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}?api-version=2018-02-01"

loResp = loHttp.PText("PUT",lcUrl,loJsonRequestBody.Emit(),"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess <> 1) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJsonToken
    RELEASE loJsonRequestBody
    CANCEL
ENDIF

? "Response Status Code: " + STR(loResp.StatusCode)

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.Load(loResp.BodyStr)
loJson.EmitCompact = 0
? loJson.Emit()

IF (loResp.StatusCode >= 300) THEN
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loJsonToken
    RELEASE loJsonRequestBody
    RELEASE loJson
    CANCEL
ENDIF

* Successful requests to create a new account return a 202 status code with an empty response body. The storage account is created asynchronously. 
* If the account already exists or is being provisioned, the request response has a 200 return code with the configuration of the existing storage account in the response body.
IF (loResp.StatusCode = 202) THEN
    ? "Azure-AsyncOperation: " + loResp.GetHeaderField("Azure-AsyncOperation")
ENDIF

IF (loResp.StatusCode = 200) THEN

    * Parse a response like this:

    * 	{
    * 	  "sku": {
    * 	    "name": "Standard_GRS",
    * 	    "tier": "Standard"
    * 	  },
    * 	  "kind": "StorageV2",
    * 	  "id": "/subscriptions/6c42643b-ebef-45f0-b917-b3583b84a57f/resourceGroups/gChilkat/providers/Microsoft.Storage/storageAccounts/chilkatsoftware",
    * 	  "name": "chilkatsoftware",
    * 	  "type": "Microsoft.Storage/storageAccounts",
    * 	  "location": "eastus2",
    * 	  "tags": {},
    * 	  "properties": {
    * 	    "networkAcls": {
    * 	      "bypass": "AzureServices",
    * 	      "virtualNetworkRules": [
    * 	      ],
    * 	      "ipRules": [
    * 	      ],
    * 	      "defaultAction": "Allow"
    * 	    },
    * 	    "supportsHttpsTrafficOnly": false,
    * 	    "encryption": {
    * 	      "services": {
    * 	        "file": {
    * 	          "enabled": true,
    * 	          "lastEnabledTime": "2019-05-14T22:18:33.2246670Z"
    * 	        },
    * 	        "blob": {
    * 	          "enabled": true,
    * 	          "lastEnabledTime": "2019-05-14T22:18:33.2246670Z"
    * 	        }
    * 	      },
    * 	      "keySource": "Microsoft.Storage"
    * 	    },
    * 	    "accessTier": "Hot",
    * 	    "provisioningState": "Succeeded",
    * 
    * 	    "creationTime": "2019-05-14T22:18:33.1309165Z",
    * 	    "primaryEndpoints": {
    * 	      "dfs": "https://chilkatsoftware.dfs.core.windows.net/",
    * 	      "web": "https://chilkatsoftware.z20.web.core.windows.net/",
    * 	      "blob": "https://chilkatsoftware.blob.core.windows.net/",
    * 	      "queue": "https://chilkatsoftware.queue.core.windows.net/",
    * 	      "table": "https://chilkatsoftware.table.core.windows.net/",
    * 	      "file": "https://chilkatsoftware.file.core.windows.net/"
    * 	    },
    * 	    "primaryLocation": "eastus2",
    * 	    "statusOfPrimary": "available",
    * 	    "secondaryLocation": "centralus",
    * 	    "statusOfSecondary": "available"
    * 	  }
    * 	}

    * Use this online tool to generate parsing code from sample JSON: 
    * Generate Parsing Code from JSON

    lcSkuName = loJson.StringOf("sku.name")
    lcSkuTier = loJson.StringOf("sku.tier")
    lcKind = loJson.StringOf("kind")
    lcId = loJson.StringOf("id")
    lcName = loJson.StringOf("name")
    lcV_type = loJson.StringOf("type")
    lcLocation = loJson.StringOf("location")
    lcPropertiesNetworkAclsBypass = loJson.StringOf("properties.networkAcls.bypass")
    lcPropertiesNetworkAclsDefaultAction = loJson.StringOf("properties.networkAcls.defaultAction")
    lnPropertiesSupportsHttpsTrafficOnly = loJson.BoolOf("properties.supportsHttpsTrafficOnly")
    lnPropertiesEncryptionServicesFileEnabled = loJson.BoolOf("properties.encryption.services.file.enabled")
    lcPropertiesEncryptionServicesFileLastEnabledTime = loJson.StringOf("properties.encryption.services.file.lastEnabledTime")
    lnPropertiesEncryptionServicesBlobEnabled = loJson.BoolOf("properties.encryption.services.blob.enabled")
    lcPropertiesEncryptionServicesBlobLastEnabledTime = loJson.StringOf("properties.encryption.services.blob.lastEnabledTime")
    lcPropertiesEncryptionKeySource = loJson.StringOf("properties.encryption.keySource")
    lcPropertiesAccessTier = loJson.StringOf("properties.accessTier")
    lcPropertiesProvisioningState = loJson.StringOf("properties.provisioningState")
    lcPropertiesCreationTime = loJson.StringOf("properties.creationTime")
    lcPropertiesPrimaryEndpointsDfs = loJson.StringOf("properties.primaryEndpoints.dfs")
    lcPropertiesPrimaryEndpointsWeb = loJson.StringOf("properties.primaryEndpoints.web")
    lcPropertiesPrimaryEndpointsBlob = loJson.StringOf("properties.primaryEndpoints.blob")
    lcPropertiesPrimaryEndpointsQueue = loJson.StringOf("properties.primaryEndpoints.queue")
    lcPropertiesPrimaryEndpointsTable = loJson.StringOf("properties.primaryEndpoints.table")
    lcPropertiesPrimaryEndpointsFile = loJson.StringOf("properties.primaryEndpoints.file")
    lcPropertiesPrimaryLocation = loJson.StringOf("properties.primaryLocation")
    lcPropertiesStatusOfPrimary = loJson.StringOf("properties.statusOfPrimary")
    lcPropertiesSecondaryLocation = loJson.StringOf("properties.secondaryLocation")
    lcPropertiesStatusOfSecondary = loJson.StringOf("properties.statusOfSecondary")
ENDIF

? "Success."

RELEASE loResp

RELEASE loHttp
RELEASE loJsonToken
RELEASE loJsonRequestBody
RELEASE loJson


 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.