CreateApp Xojo Example
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Dim rest As New Chilkat.Rest
Dim success As Boolean
Dim authAws As New Chilkat.AuthAws
authAws.AccessKey = "AWS_ACCESS_KEY"
authAws.SecretKey = "AWS_SECRET_KEY"
// Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
authAws.Region = "us-west-2"
authAws.ServiceName = "amplify"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
success = rest.SetAuthAws(authAws)
// URL: https://amplify.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect("amplify.us-west-2.amazonaws.com",443,True,True)
If (success <> True) Then
System.DebugLog("ConnectFailReason: " + Str(rest.ConnectFailReason))
System.DebugLog(rest.LastErrorText)
Return
End If
// The following code creates the JSON request body.
// The JSON created by this code is shown below.
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
Dim json As New Chilkat.JsonObject
success = json.UpdateString("accessToken","string")
success = json.UpdateString("autoBranchCreationConfig.basicAuthCredentials","string")
success = json.UpdateString("autoBranchCreationConfig.buildSpec","string")
success = json.UpdateInt("autoBranchCreationConfig.enableAutoBuild",123)
success = json.UpdateInt("autoBranchCreationConfig.enableBasicAuth",123)
success = json.UpdateInt("autoBranchCreationConfig.enablePerformanceMode",123)
success = json.UpdateInt("autoBranchCreationConfig.enablePullRequestPreview",123)
success = json.UpdateString("autoBranchCreationConfig.environmentVariables.string","string")
success = json.UpdateString("autoBranchCreationConfig.framework","string")
success = json.UpdateString("autoBranchCreationConfig.pullRequestEnvironmentName","string")
success = json.UpdateString("autoBranchCreationConfig.stage","string")
success = json.UpdateString("autoBranchCreationPatterns[0]","string")
success = json.UpdateString("basicAuthCredentials","string")
success = json.UpdateString("buildSpec","string")
success = json.UpdateString("customHeaders","string")
success = json.UpdateString("customRules[0].condition","string")
success = json.UpdateString("customRules[0].source","string")
success = json.UpdateString("customRules[0].status","string")
success = json.UpdateString("customRules[0].target","string")
success = json.UpdateString("description","string")
success = json.UpdateInt("enableAutoBranchCreation",123)
success = json.UpdateInt("enableBasicAuth",123)
success = json.UpdateInt("enableBranchAutoBuild",123)
success = json.UpdateInt("enableBranchAutoDeletion",123)
success = json.UpdateString("environmentVariables.string","string")
success = json.UpdateString("iamServiceRoleArn","string")
success = json.UpdateString("name","string")
success = json.UpdateString("oauthToken","string")
success = json.UpdateString("platform","string")
success = json.UpdateString("repository","string")
success = json.UpdateString("tags.string","string")
// The JSON request body created by the above code:
// {
// "accessToken": "string",
// "autoBranchCreationConfig": {
// "basicAuthCredentials": "string",
// "buildSpec": "string",
// "enableAutoBuild": boolean,
// "enableBasicAuth": boolean,
// "enablePerformanceMode": boolean,
// "enablePullRequestPreview": boolean,
// "environmentVariables": {
// "string": "string"
// },
// "framework": "string",
// "pullRequestEnvironmentName": "string",
// "stage": "string"
// },
// "autoBranchCreationPatterns": [
// "string"
// ],
// "basicAuthCredentials": "string",
// "buildSpec": "string",
// "customHeaders": "string",
// "customRules": [
// {
// "condition": "string",
// "source": "string",
// "status": "string",
// "target": "string"
// }
// ],
// "description": "string",
// "enableAutoBranchCreation": boolean,
// "enableBasicAuth": boolean,
// "enableBranchAutoBuild": boolean,
// "enableBranchAutoDeletion": boolean,
// "environmentVariables": {
// "string": "string"
// },
// "iamServiceRoleArn": "string",
// "name": "string",
// "oauthToken": "string",
// "platform": "string",
// "repository": "string",
// "tags": {
// "string": "string"
// }
// }
success = rest.AddHeader("Content-Type","application/x-amz-json-1.1")
success = rest.AddHeader("X-Amz-Target","CreateApp")
Dim sbRequestBody As New Chilkat.StringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST","/apps",sbRequestBody,sbResponseBody)
If (success <> True) Then
System.DebugLog(rest.LastErrorText)
Return
End If
Dim respStatusCode As Int32
respStatusCode = rest.ResponseStatusCode
System.DebugLog("response status code = " + Str(respStatusCode))
If (respStatusCode <> 200) Then
System.DebugLog("Response Header:")
System.DebugLog(rest.ResponseHeader)
System.DebugLog("Response Body:")
System.DebugLog(sbResponseBody.GetAsString())
Return
End If
Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
Dim strVal As String
Dim condition As String
Dim source As String
Dim status As String
Dim target As String
Dim AppArn As String
AppArn = jResp.StringOf("app.appArn")
Dim AppId As String
AppId = jResp.StringOf("app.appId")
Dim BasicAuthCredentials As String
BasicAuthCredentials = jResp.StringOf("app.autoBranchCreationConfig.basicAuthCredentials")
Dim BuildSpec As String
BuildSpec = jResp.StringOf("app.autoBranchCreationConfig.buildSpec")
Dim EnableAutoBuild As Int32
EnableAutoBuild = jResp.IntOf("app.autoBranchCreationConfig.enableAutoBuild")
Dim EnableBasicAuth As Int32
EnableBasicAuth = jResp.IntOf("app.autoBranchCreationConfig.enableBasicAuth")
Dim EnablePerformanceMode As Int32
EnablePerformanceMode = jResp.IntOf("app.autoBranchCreationConfig.enablePerformanceMode")
Dim EnablePullRequestPreview As Int32
EnablePullRequestPreview = jResp.IntOf("app.autoBranchCreationConfig.enablePullRequestPreview")
Dim v_String As String
v_String = jResp.StringOf("app.autoBranchCreationConfig.environmentVariables.string")
Dim Framework As String
Framework = jResp.StringOf("app.autoBranchCreationConfig.framework")
Dim PullRequestEnvironmentName As String
PullRequestEnvironmentName = jResp.StringOf("app.autoBranchCreationConfig.pullRequestEnvironmentName")
Dim Stage As String
Stage = jResp.StringOf("app.autoBranchCreationConfig.stage")
Dim appBasicAuthCredentials As String
appBasicAuthCredentials = jResp.StringOf("app.basicAuthCredentials")
Dim appBuildSpec As String
appBuildSpec = jResp.StringOf("app.buildSpec")
Dim CreateTime As Int32
CreateTime = jResp.IntOf("app.createTime")
Dim CustomHeaders As String
CustomHeaders = jResp.StringOf("app.customHeaders")
Dim DefaultDomain As String
DefaultDomain = jResp.StringOf("app.defaultDomain")
Dim Description As String
Description = jResp.StringOf("app.description")
Dim EnableAutoBranchCreation As Int32
EnableAutoBranchCreation = jResp.IntOf("app.enableAutoBranchCreation")
Dim appEnableBasicAuth As Int32
appEnableBasicAuth = jResp.IntOf("app.enableBasicAuth")
Dim EnableBranchAutoBuild As Int32
EnableBranchAutoBuild = jResp.IntOf("app.enableBranchAutoBuild")
Dim EnableBranchAutoDeletion As Int32
EnableBranchAutoDeletion = jResp.IntOf("app.enableBranchAutoDeletion")
Dim EnvironmentVariablesString As String
EnvironmentVariablesString = jResp.StringOf("app.environmentVariables.string")
Dim IamServiceRoleArn As String
IamServiceRoleArn = jResp.StringOf("app.iamServiceRoleArn")
Dim Name As String
Name = jResp.StringOf("app.name")
Dim Platform As String
Platform = jResp.StringOf("app.platform")
Dim BranchName As String
BranchName = jResp.StringOf("app.productionBranch.branchName")
Dim LastDeployTime As Int32
LastDeployTime = jResp.IntOf("app.productionBranch.lastDeployTime")
Dim Status As String
Status = jResp.StringOf("app.productionBranch.status")
Dim ThumbnailUrl As String
ThumbnailUrl = jResp.StringOf("app.productionBranch.thumbnailUrl")
Dim Repository As String
Repository = jResp.StringOf("app.repository")
Dim RepositoryCloneMethod As String
RepositoryCloneMethod = jResp.StringOf("app.repositoryCloneMethod")
Dim TagsString As String
TagsString = jResp.StringOf("app.tags.string")
Dim UpdateTime As Int32
UpdateTime = jResp.IntOf("app.updateTime")
Dim i As Int32
i = 0
Dim count_i As Int32
count_i = jResp.SizeOfArray("app.autoBranchCreationPatterns")
While i < count_i
jResp.I = i
strVal = jResp.StringOf("app.autoBranchCreationPatterns[i]")
i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("app.customRules")
While i < count_i
jResp.I = i
condition = jResp.StringOf("app.customRules[i].condition")
source = jResp.StringOf("app.customRules[i].source")
status = jResp.StringOf("app.customRules[i].status")
target = jResp.StringOf("app.customRules[i].target")
i = i + 1
Wend
// A sample JSON response body parsed by the above code:
// {
// "app": {
// "appArn": "string",
// "appId": "string",
// "autoBranchCreationConfig": {
// "basicAuthCredentials": "string",
// "buildSpec": "string",
// "enableAutoBuild": boolean,
// "enableBasicAuth": boolean,
// "enablePerformanceMode": boolean,
// "enablePullRequestPreview": boolean,
// "environmentVariables": {
// "string": "string"
// },
// "framework": "string",
// "pullRequestEnvironmentName": "string",
// "stage": "string"
// },
// "autoBranchCreationPatterns": [
// "string"
// ],
// "basicAuthCredentials": "string",
// "buildSpec": "string",
// "createTime": number,
// "customHeaders": "string",
// "customRules": [
// {
// "condition": "string",
// "source": "string",
// "status": "string",
// "target": "string"
// }
// ],
// "defaultDomain": "string",
// "description": "string",
// "enableAutoBranchCreation": boolean,
// "enableBasicAuth": boolean,
// "enableBranchAutoBuild": boolean,
// "enableBranchAutoDeletion": boolean,
// "environmentVariables": {
// "string": "string"
// },
// "iamServiceRoleArn": "string",
// "name": "string",
// "platform": "string",
// "productionBranch": {
// "branchName": "string",
// "lastDeployTime": number,
// "status": "string",
// "thumbnailUrl": "string"
// },
// "repository": "string",
// "repositoryCloneMethod": "string",
// "tags": {
// "string": "string"
// },
// "updateTime": number
// }
// }