Chilkat Online Tools

DescribeActivities VB6 Example

Amazon WorkDocs

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

Dim rest As New ChilkatRest
Dim success As Long

Dim authAws As New ChilkatAuthAws
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 = "workdocs"
' SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
success = rest.SetAuthAws(authAws)

' URL: https://workdocs.us-west-2.amazonaws.com/
' Use the same region as specified above.
success = rest.Connect("workdocs.us-west-2.amazonaws.com",443,1,1)
If (success <> 1) Then
    Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
    Debug.Print rest.LastErrorText
    Exit Sub
End If

success = rest.AddHeader("Content-Type","application/x-amz-json-1.1")
success = rest.AddHeader("X-Amz-Target","DescribeActivities")

Dim sbResponseBody As New ChilkatStringBuilder
success = rest.FullRequestNoBodySb("GET","/api/v1/activities",sbResponseBody)
If (success <> 1) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

Dim respStatusCode As Long
respStatusCode = rest.ResponseStatusCode
Debug.Print "response status code = " & respStatusCode
If (respStatusCode <> 200) Then
    Debug.Print "Response Header:"
    Debug.Print rest.ResponseHeader
    Debug.Print "Response Body:"
    Debug.Print sbResponseBody.GetAsString()
    Exit Sub
End If

Dim jResp As New ChilkatJsonObject
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 CommentId As String
Dim CommentStatus As String
Dim CreatedTimestamp As Long
Dim EmailAddress As String
Dim GivenName As String
Dim Id As String
Dim Locale As String
Dim ModifiedTimestamp As Long
Dim OrganizationId As String
Dim RecycleBinFolderId As String
Dim RootFolderId As String
Dim Status As String
Dim StorageAllocatedInBytes As Long
Dim StorageType As String
Dim StorageUtilizedInBytes As Long
Dim Surname As String
Dim TimeZoneId As String
Dim v_Type As String
Dim Username As String
Dim CommentMetadataCreatedTimestamp As Long
Dim RecipientId As String
Dim InitiatorEmailAddress As String
Dim InitiatorGivenName As String
Dim InitiatorId As String
Dim InitiatorSurname As String
Dim InitiatorUsername As String
Dim IsIndirectActivity As Long
Dim OriginalParentId As String
Dim Name As String
Dim OriginalName As String
Dim OwnerEmailAddress As String
Dim OwnerGivenName As String
Dim OwnerId As String
Dim OwnerSurname As String
Dim OwnerUsername As String
Dim ParentId As String
Dim OriginalParentType As String
Dim VersionId As String
Dim ResourceMetadataId As String
Dim ResourceMetadataName As String
Dim ResourceMetadataOriginalName As String
Dim ResourceMetadataParentId As String
Dim ResourceMetadataType As String
Dim ResourceMetadataVersionId As String
Dim TimeStamp As Long
Dim j As Long
Dim count_j As Long

Dim Marker As String
Marker = jResp.StringOf("Marker")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("UserActivities")
Do While i < count_i
    jResp.I = i
    CommentId = jResp.StringOf("UserActivities[i].CommentMetadata.CommentId")
    CommentStatus = jResp.StringOf("UserActivities[i].CommentMetadata.CommentStatus")
    CreatedTimestamp = jResp.IntOf("UserActivities[i].CommentMetadata.Contributor.CreatedTimestamp")
    EmailAddress = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.EmailAddress")
    GivenName = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.GivenName")
    Id = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Id")
    Locale = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Locale")
    ModifiedTimestamp = jResp.IntOf("UserActivities[i].CommentMetadata.Contributor.ModifiedTimestamp")
    OrganizationId = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.OrganizationId")
    RecycleBinFolderId = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.RecycleBinFolderId")
    RootFolderId = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.RootFolderId")
    Status = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Status")
    StorageAllocatedInBytes = jResp.IntOf("UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageAllocatedInBytes")
    StorageType = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageType")
    StorageUtilizedInBytes = jResp.IntOf("UserActivities[i].CommentMetadata.Contributor.Storage.StorageUtilizedInBytes")
    Surname = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Surname")
    TimeZoneId = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.TimeZoneId")
    v_Type = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Type")
    Username = jResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Username")
    CommentMetadataCreatedTimestamp = jResp.IntOf("UserActivities[i].CommentMetadata.CreatedTimestamp")
    RecipientId = jResp.StringOf("UserActivities[i].CommentMetadata.RecipientId")
    InitiatorEmailAddress = jResp.StringOf("UserActivities[i].Initiator.EmailAddress")
    InitiatorGivenName = jResp.StringOf("UserActivities[i].Initiator.GivenName")
    InitiatorId = jResp.StringOf("UserActivities[i].Initiator.Id")
    InitiatorSurname = jResp.StringOf("UserActivities[i].Initiator.Surname")
    InitiatorUsername = jResp.StringOf("UserActivities[i].Initiator.Username")
    IsIndirectActivity = jResp.IntOf("UserActivities[i].IsIndirectActivity")
    OrganizationId = jResp.StringOf("UserActivities[i].OrganizationId")
    OriginalParentId = jResp.StringOf("UserActivities[i].OriginalParent.Id")
    Name = jResp.StringOf("UserActivities[i].OriginalParent.Name")
    OriginalName = jResp.StringOf("UserActivities[i].OriginalParent.OriginalName")
    OwnerEmailAddress = jResp.StringOf("UserActivities[i].OriginalParent.Owner.EmailAddress")
    OwnerGivenName = jResp.StringOf("UserActivities[i].OriginalParent.Owner.GivenName")
    OwnerId = jResp.StringOf("UserActivities[i].OriginalParent.Owner.Id")
    OwnerSurname = jResp.StringOf("UserActivities[i].OriginalParent.Owner.Surname")
    OwnerUsername = jResp.StringOf("UserActivities[i].OriginalParent.Owner.Username")
    ParentId = jResp.StringOf("UserActivities[i].OriginalParent.ParentId")
    OriginalParentType = jResp.StringOf("UserActivities[i].OriginalParent.Type")
    VersionId = jResp.StringOf("UserActivities[i].OriginalParent.VersionId")
    ResourceMetadataId = jResp.StringOf("UserActivities[i].ResourceMetadata.Id")
    ResourceMetadataName = jResp.StringOf("UserActivities[i].ResourceMetadata.Name")
    ResourceMetadataOriginalName = jResp.StringOf("UserActivities[i].ResourceMetadata.OriginalName")
    OwnerEmailAddress = jResp.StringOf("UserActivities[i].ResourceMetadata.Owner.EmailAddress")
    OwnerGivenName = jResp.StringOf("UserActivities[i].ResourceMetadata.Owner.GivenName")
    OwnerId = jResp.StringOf("UserActivities[i].ResourceMetadata.Owner.Id")
    OwnerSurname = jResp.StringOf("UserActivities[i].ResourceMetadata.Owner.Surname")
    OwnerUsername = jResp.StringOf("UserActivities[i].ResourceMetadata.Owner.Username")
    ResourceMetadataParentId = jResp.StringOf("UserActivities[i].ResourceMetadata.ParentId")
    ResourceMetadataType = jResp.StringOf("UserActivities[i].ResourceMetadata.Type")
    ResourceMetadataVersionId = jResp.StringOf("UserActivities[i].ResourceMetadata.VersionId")
    TimeStamp = jResp.IntOf("UserActivities[i].TimeStamp")
    v_Type = jResp.StringOf("UserActivities[i].Type")
    j = 0
    count_j = jResp.SizeOfArray("UserActivities[i].Participants.Groups")
    Do While j < count_j
        jResp.J = j
        Id = jResp.StringOf("UserActivities[i].Participants.Groups[j].Id")
        Name = jResp.StringOf("UserActivities[i].Participants.Groups[j].Name")
        j = j + 1
    Loop
    j = 0
    count_j = jResp.SizeOfArray("UserActivities[i].Participants.Users")
    Do While j < count_j
        jResp.J = j
        EmailAddress = jResp.StringOf("UserActivities[i].Participants.Users[j].EmailAddress")
        GivenName = jResp.StringOf("UserActivities[i].Participants.Users[j].GivenName")
        Id = jResp.StringOf("UserActivities[i].Participants.Users[j].Id")
        Surname = jResp.StringOf("UserActivities[i].Participants.Users[j].Surname")
        Username = jResp.StringOf("UserActivities[i].Participants.Users[j].Username")
        j = j + 1
    Loop
    i = i + 1
Loop

' A sample JSON response body parsed by the above code:

' {
'   "Marker": "string",
'   "UserActivities": [
'     {
'       "CommentMetadata": {
'         "CommentId": "string",
'         "CommentStatus": "string",
'         "Contributor": {
'           "CreatedTimestamp": number,
'           "EmailAddress": "string",
'           "GivenName": "string",
'           "Id": "string",
'           "Locale": "string",
'           "ModifiedTimestamp": number,
'           "OrganizationId": "string",
'           "RecycleBinFolderId": "string",
'           "RootFolderId": "string",
'           "Status": "string",
'           "Storage": {
'             "StorageRule": {
'               "StorageAllocatedInBytes": number,
'               "StorageType": "string"
'             },
'             "StorageUtilizedInBytes": number
'           },
'           "Surname": "string",
'           "TimeZoneId": "string",
'           "Type": "string",
'           "Username": "string"
'         },
'         "CreatedTimestamp": number,
'         "RecipientId": "string"
'       },
'       "Initiator": {
'         "EmailAddress": "string",
'         "GivenName": "string",
'         "Id": "string",
'         "Surname": "string",
'         "Username": "string"
'       },
'       "IsIndirectActivity": boolean,
'       "OrganizationId": "string",
'       "OriginalParent": {
'         "Id": "string",
'         "Name": "string",
'         "OriginalName": "string",
'         "Owner": {
'           "EmailAddress": "string",
'           "GivenName": "string",
'           "Id": "string",
'           "Surname": "string",
'           "Username": "string"
'         },
'         "ParentId": "string",
'         "Type": "string",
'         "VersionId": "string"
'       },
'       "Participants": {
'         "Groups": [
'           {
'             "Id": "string",
'             "Name": "string"
'           }
'         ],
'         "Users": [
'           {
'             "EmailAddress": "string",
'             "GivenName": "string",
'             "Id": "string",
'             "Surname": "string",
'             "Username": "string"
'           }
'         ]
'       },
'       "ResourceMetadata": {
'         "Id": "string",
'         "Name": "string",
'         "OriginalName": "string",
'         "Owner": {
'           "EmailAddress": "string",
'           "GivenName": "string",
'           "Id": "string",
'           "Surname": "string",
'           "Username": "string"
'         },
'         "ParentId": "string",
'         "Type": "string",
'         "VersionId": "string"
'       },
'       "TimeStamp": number,
'       "Type": "string"
'     }
'   ]
' }