DescribeActivities delphiDll Example
var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
CommentId: PWideChar;
CommentStatus: PWideChar;
CreatedTimestamp: Integer;
EmailAddress: PWideChar;
GivenName: PWideChar;
Id: PWideChar;
Locale: PWideChar;
ModifiedTimestamp: Integer;
OrganizationId: PWideChar;
RecycleBinFolderId: PWideChar;
RootFolderId: PWideChar;
Status: PWideChar;
StorageAllocatedInBytes: Integer;
StorageType: PWideChar;
StorageUtilizedInBytes: Integer;
Surname: PWideChar;
TimeZoneId: PWideChar;
v_Type: PWideChar;
Username: PWideChar;
CommentMetadataCreatedTimestamp: Integer;
RecipientId: PWideChar;
InitiatorEmailAddress: PWideChar;
InitiatorGivenName: PWideChar;
InitiatorId: PWideChar;
InitiatorSurname: PWideChar;
InitiatorUsername: PWideChar;
IsIndirectActivity: Integer;
OriginalParentId: PWideChar;
Name: PWideChar;
OriginalName: PWideChar;
OwnerEmailAddress: PWideChar;
OwnerGivenName: PWideChar;
OwnerId: PWideChar;
OwnerSurname: PWideChar;
OwnerUsername: PWideChar;
ParentId: PWideChar;
OriginalParentType: PWideChar;
VersionId: PWideChar;
ResourceMetadataId: PWideChar;
ResourceMetadataName: PWideChar;
ResourceMetadataOriginalName: PWideChar;
ResourceMetadataParentId: PWideChar;
ResourceMetadataType: PWideChar;
ResourceMetadataVersionId: PWideChar;
TimeStamp: Integer;
j: Integer;
count_j: Integer;
Marker: PWideChar;
i: Integer;
count_i: Integer;
begin
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
rest := CkRest_Create();
authAws := CkAuthAws_Create();
CkAuthAws_putAccessKey(authAws,'AWS_ACCESS_KEY');
CkAuthAws_putSecretKey(authAws,'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.)
CkAuthAws_putRegion(authAws,'us-west-2');
CkAuthAws_putServiceName(authAws,'workdocs');
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws(rest,authAws);
// URL: https://workdocs.us-west-2.amazonaws.com/
// Use the same region as specified above.
success := CkRest_Connect(rest,'workdocs.us-west-2.amazonaws.com',443,True,True);
if (success <> True) then
begin
Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
CkRest_AddHeader(rest,'Content-Type','application/x-amz-json-1.1');
CkRest_AddHeader(rest,'X-Amz-Target','DescribeActivities');
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/api/v1/activities',sbResponseBody);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
respStatusCode := CkRest_getResponseStatusCode(rest);
Memo1.Lines.Add('response status code = ' + IntToStr(respStatusCode));
if (respStatusCode <> 200) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkRest__responseHeader(rest));
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
Exit;
end;
jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,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
Marker := CkJsonObject__stringOf(jResp,'Marker');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'UserActivities');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
CommentId := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.CommentId');
CommentStatus := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.CommentStatus');
CreatedTimestamp := CkJsonObject_IntOf(jResp,'UserActivities[i].CommentMetadata.Contributor.CreatedTimestamp');
EmailAddress := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.EmailAddress');
GivenName := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.GivenName');
Id := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Id');
Locale := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Locale');
ModifiedTimestamp := CkJsonObject_IntOf(jResp,'UserActivities[i].CommentMetadata.Contributor.ModifiedTimestamp');
OrganizationId := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.OrganizationId');
RecycleBinFolderId := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.RecycleBinFolderId');
RootFolderId := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.RootFolderId');
Status := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Status');
StorageAllocatedInBytes := CkJsonObject_IntOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageAllocatedInBytes');
StorageType := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageType');
StorageUtilizedInBytes := CkJsonObject_IntOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Storage.StorageUtilizedInBytes');
Surname := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Surname');
TimeZoneId := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.TimeZoneId');
v_Type := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Type');
Username := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.Contributor.Username');
CommentMetadataCreatedTimestamp := CkJsonObject_IntOf(jResp,'UserActivities[i].CommentMetadata.CreatedTimestamp');
RecipientId := CkJsonObject__stringOf(jResp,'UserActivities[i].CommentMetadata.RecipientId');
InitiatorEmailAddress := CkJsonObject__stringOf(jResp,'UserActivities[i].Initiator.EmailAddress');
InitiatorGivenName := CkJsonObject__stringOf(jResp,'UserActivities[i].Initiator.GivenName');
InitiatorId := CkJsonObject__stringOf(jResp,'UserActivities[i].Initiator.Id');
InitiatorSurname := CkJsonObject__stringOf(jResp,'UserActivities[i].Initiator.Surname');
InitiatorUsername := CkJsonObject__stringOf(jResp,'UserActivities[i].Initiator.Username');
IsIndirectActivity := CkJsonObject_IntOf(jResp,'UserActivities[i].IsIndirectActivity');
OrganizationId := CkJsonObject__stringOf(jResp,'UserActivities[i].OrganizationId');
OriginalParentId := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.Id');
Name := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.Name');
OriginalName := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.OriginalName');
OwnerEmailAddress := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.Owner.EmailAddress');
OwnerGivenName := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.Owner.GivenName');
OwnerId := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.Owner.Id');
OwnerSurname := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.Owner.Surname');
OwnerUsername := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.Owner.Username');
ParentId := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.ParentId');
OriginalParentType := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.Type');
VersionId := CkJsonObject__stringOf(jResp,'UserActivities[i].OriginalParent.VersionId');
ResourceMetadataId := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.Id');
ResourceMetadataName := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.Name');
ResourceMetadataOriginalName := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.OriginalName');
OwnerEmailAddress := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.Owner.EmailAddress');
OwnerGivenName := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.Owner.GivenName');
OwnerId := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.Owner.Id');
OwnerSurname := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.Owner.Surname');
OwnerUsername := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.Owner.Username');
ResourceMetadataParentId := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.ParentId');
ResourceMetadataType := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.Type');
ResourceMetadataVersionId := CkJsonObject__stringOf(jResp,'UserActivities[i].ResourceMetadata.VersionId');
TimeStamp := CkJsonObject_IntOf(jResp,'UserActivities[i].TimeStamp');
v_Type := CkJsonObject__stringOf(jResp,'UserActivities[i].Type');
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'UserActivities[i].Participants.Groups');
while j < count_j do
begin
CkJsonObject_putJ(jResp,j);
Id := CkJsonObject__stringOf(jResp,'UserActivities[i].Participants.Groups[j].Id');
Name := CkJsonObject__stringOf(jResp,'UserActivities[i].Participants.Groups[j].Name');
j := j + 1;
end;
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'UserActivities[i].Participants.Users');
while j < count_j do
begin
CkJsonObject_putJ(jResp,j);
EmailAddress := CkJsonObject__stringOf(jResp,'UserActivities[i].Participants.Users[j].EmailAddress');
GivenName := CkJsonObject__stringOf(jResp,'UserActivities[i].Participants.Users[j].GivenName');
Id := CkJsonObject__stringOf(jResp,'UserActivities[i].Participants.Users[j].Id');
Surname := CkJsonObject__stringOf(jResp,'UserActivities[i].Participants.Users[j].Surname');
Username := CkJsonObject__stringOf(jResp,'UserActivities[i].Participants.Users[j].Username');
j := j + 1;
end;
i := i + 1;
end;
// 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"
// }
// ]
// }
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);