GetTest 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 = "devicefarm"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
success = rest.SetAuthAws(authAws)
// URL: https://devicefarm.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect("devicefarm.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("arn","string")
// The JSON request body created by the above code:
// {
// "arn": "string"
// }
success = rest.AddHeader("Content-Type","application/x-amz-json-1.1")
success = rest.AddHeader("X-Amz-Target","DeviceFarm_20150623.GetTest")
Dim sbRequestBody As New Chilkat.StringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST","/",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 Arn As String
Arn = jResp.StringOf("test.arn")
Dim Errored As Int32
Errored = jResp.IntOf("test.counters.errored")
Dim Failed As Int32
Failed = jResp.IntOf("test.counters.failed")
Dim Passed As Int32
Passed = jResp.IntOf("test.counters.passed")
Dim Skipped As Int32
Skipped = jResp.IntOf("test.counters.skipped")
Dim Stopped As Int32
Stopped = jResp.IntOf("test.counters.stopped")
Dim Total As Int32
Total = jResp.IntOf("test.counters.total")
Dim Warned As Int32
Warned = jResp.IntOf("test.counters.warned")
Dim Created As Int32
Created = jResp.IntOf("test.created")
Dim Metered As Int32
Metered = jResp.IntOf("test.deviceMinutes.metered")
Dim DeviceMinutesTotal As Int32
DeviceMinutesTotal = jResp.IntOf("test.deviceMinutes.total")
Dim Unmetered As Int32
Unmetered = jResp.IntOf("test.deviceMinutes.unmetered")
Dim Message As String
Message = jResp.StringOf("test.message")
Dim Name As String
Name = jResp.StringOf("test.name")
Dim Result As String
Result = jResp.StringOf("test.result")
Dim Started As Int32
Started = jResp.IntOf("test.started")
Dim Status As String
Status = jResp.StringOf("test.status")
Dim testStopped As Int32
testStopped = jResp.IntOf("test.stopped")
Dim v_Type As String
v_Type = jResp.StringOf("test.type")
// A sample JSON response body parsed by the above code:
// {
// "test": {
// "arn": "string",
// "counters": {
// "errored": number,
// "failed": number,
// "passed": number,
// "skipped": number,
// "stopped": number,
// "total": number,
// "warned": number
// },
// "created": number,
// "deviceMinutes": {
// "metered": number,
// "total": number,
// "unmetered": number
// },
// "message": "string",
// "name": "string",
// "result": "string",
// "started": number,
// "status": "string",
// "stopped": number,
// "type": "string"
// }
// }