Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Android™ Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Android™) Azure Create Storage Account

Demonstrates how to create an Azure storage account.

Chilkat Android™ Downloads

Android™ Java Libraries

Android C/C++ Libraries

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();

    // Load an OAuth2 access token previously fetched by this example:  Get Azure OAuth2 Access Token
    CkJsonObject jsonToken = new CkJsonObject();
    boolean success = jsonToken.LoadFile("qa_data/tokens/azureToken.json");
    // Assuming success..
    http.put_AuthToken(jsonToken.stringOf("access_token"));
    Log.i(TAG, "AuthToken: " + http.authToken());

    http.put_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

    CkJsonObject jsonRequestBody = new CkJsonObject();
    jsonRequestBody.UpdateString("sku.name","Standard_GRS");
    jsonRequestBody.UpdateString("kind","StorageV2");
    jsonRequestBody.UpdateString("location","eastus2");

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

    CkHttpResponse resp = http.PText("PUT",url,jsonRequestBody.emit(),"utf-8","application/json",false,false);
    if (http.get_LastMethodSuccess() != true) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    Log.i(TAG, "Response Status Code: " + String.valueOf(resp.get_StatusCode()));

    CkJsonObject json = new CkJsonObject();
    json.Load(resp.bodyStr());
    json.put_EmitCompact(false);
    Log.i(TAG, json.emit());

    if (resp.get_StatusCode() >= 300) {
        Log.i(TAG, "Failed.");

        return;
        }

    // 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 (resp.get_StatusCode() == 202) {
        Log.i(TAG, "Azure-AsyncOperation: " + resp.getHeaderField("Azure-AsyncOperation"));
        }

    if (resp.get_StatusCode() == 200) {

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

        String skuName;
        String skuTier;
        String kind;
        String id;
        String name;
        String v_type;
        String location;
        String propertiesNetworkAclsBypass;
        String propertiesNetworkAclsDefaultAction;
        boolean propertiesSupportsHttpsTrafficOnly;
        boolean propertiesEncryptionServicesFileEnabled;
        String propertiesEncryptionServicesFileLastEnabledTime;
        boolean propertiesEncryptionServicesBlobEnabled;
        String propertiesEncryptionServicesBlobLastEnabledTime;
        String propertiesEncryptionKeySource;
        String propertiesAccessTier;
        String propertiesProvisioningState;
        String propertiesCreationTime;
        String propertiesPrimaryEndpointsDfs;
        String propertiesPrimaryEndpointsWeb;
        String propertiesPrimaryEndpointsBlob;
        String propertiesPrimaryEndpointsQueue;
        String propertiesPrimaryEndpointsTable;
        String propertiesPrimaryEndpointsFile;
        String propertiesPrimaryLocation;
        String propertiesStatusOfPrimary;
        String propertiesSecondaryLocation;
        String propertiesStatusOfSecondary;
        int i;
        int count_i;

        skuName = json.stringOf("sku.name");
        skuTier = json.stringOf("sku.tier");
        kind = json.stringOf("kind");
        id = json.stringOf("id");
        name = json.stringOf("name");
        v_type = json.stringOf("type");
        location = json.stringOf("location");
        propertiesNetworkAclsBypass = json.stringOf("properties.networkAcls.bypass");
        propertiesNetworkAclsDefaultAction = json.stringOf("properties.networkAcls.defaultAction");
        propertiesSupportsHttpsTrafficOnly = json.BoolOf("properties.supportsHttpsTrafficOnly");
        propertiesEncryptionServicesFileEnabled = json.BoolOf("properties.encryption.services.file.enabled");
        propertiesEncryptionServicesFileLastEnabledTime = json.stringOf("properties.encryption.services.file.lastEnabledTime");
        propertiesEncryptionServicesBlobEnabled = json.BoolOf("properties.encryption.services.blob.enabled");
        propertiesEncryptionServicesBlobLastEnabledTime = json.stringOf("properties.encryption.services.blob.lastEnabledTime");
        propertiesEncryptionKeySource = json.stringOf("properties.encryption.keySource");
        propertiesAccessTier = json.stringOf("properties.accessTier");
        propertiesProvisioningState = json.stringOf("properties.provisioningState");
        propertiesCreationTime = json.stringOf("properties.creationTime");
        propertiesPrimaryEndpointsDfs = json.stringOf("properties.primaryEndpoints.dfs");
        propertiesPrimaryEndpointsWeb = json.stringOf("properties.primaryEndpoints.web");
        propertiesPrimaryEndpointsBlob = json.stringOf("properties.primaryEndpoints.blob");
        propertiesPrimaryEndpointsQueue = json.stringOf("properties.primaryEndpoints.queue");
        propertiesPrimaryEndpointsTable = json.stringOf("properties.primaryEndpoints.table");
        propertiesPrimaryEndpointsFile = json.stringOf("properties.primaryEndpoints.file");
        propertiesPrimaryLocation = json.stringOf("properties.primaryLocation");
        propertiesStatusOfPrimary = json.stringOf("properties.statusOfPrimary");
        propertiesSecondaryLocation = json.stringOf("properties.secondaryLocation");
        propertiesStatusOfSecondary = json.stringOf("properties.statusOfSecondary");
        }

    Log.i(TAG, "Success.");


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

 

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