Chilkat Online Tools

DescribeUserHierarchyGroup C# Example

Amazon Connect

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

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

Chilkat.AuthAws authAws = 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 = "connect";
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws);

// URL: https://connect.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect("connect.us-west-2.amazonaws.com",443,true,true);
if (success != true) {
    Debug.WriteLine("ConnectFailReason: " + Convert.ToString(rest.ConnectFailReason));
    Debug.WriteLine(rest.LastErrorText);
    return;
}

rest.AddHeader("Content-Type","application/x-amz-json-1.1");
rest.AddHeader("X-Amz-Target","DescribeUserHierarchyGroup");

Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
success = rest.FullRequestNoBodySb("GET","/user-hierarchy-groups/{InstanceId}/{HierarchyGroupId}",sbResponseBody);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

int respStatusCode = rest.ResponseStatusCode;
Debug.WriteLine("response status code = " + Convert.ToString(respStatusCode));
if (respStatusCode != 200) {
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(rest.ResponseHeader);
    Debug.WriteLine("Response Body:");
    Debug.WriteLine(sbResponseBody.GetAsString());
    return;
}

Chilkat.JsonObject jResp = new Chilkat.JsonObject();
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

string Arn = jResp.StringOf("HierarchyGroup.Arn");
string LevelFiveArn = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelFive.Arn");
string Id = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelFive.Id");
string Name = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelFive.Name");
string LevelFourArn = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelFour.Arn");
string LevelFourId = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelFour.Id");
string LevelFourName = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelFour.Name");
string LevelOneArn = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelOne.Arn");
string LevelOneId = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelOne.Id");
string LevelOneName = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelOne.Name");
string LevelThreeArn = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelThree.Arn");
string LevelThreeId = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelThree.Id");
string LevelThreeName = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelThree.Name");
string LevelTwoArn = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelTwo.Arn");
string LevelTwoId = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelTwo.Id");
string LevelTwoName = jResp.StringOf("HierarchyGroup.HierarchyPath.LevelTwo.Name");
string HierarchyGroupId = jResp.StringOf("HierarchyGroup.Id");
string LevelId = jResp.StringOf("HierarchyGroup.LevelId");
string HierarchyGroupName = jResp.StringOf("HierarchyGroup.Name");
string v_String = jResp.StringOf("HierarchyGroup.Tags.string");

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

// {
//   "HierarchyGroup": {
//     "Arn": "string",
//     "HierarchyPath": {
//       "LevelFive": {
//         "Arn": "string",
//         "Id": "string",
//         "Name": "string"
//       },
//       "LevelFour": {
//         "Arn": "string",
//         "Id": "string",
//         "Name": "string"
//       },
//       "LevelOne": {
//         "Arn": "string",
//         "Id": "string",
//         "Name": "string"
//       },
//       "LevelThree": {
//         "Arn": "string",
//         "Id": "string",
//         "Name": "string"
//       },
//       "LevelTwo": {
//         "Arn": "string",
//         "Id": "string",
//         "Name": "string"
//       }
//     },
//     "Id": "string",
//     "LevelId": "string",
//     "Name": "string",
//     "Tags": {
//       "string": "string"
//     }
//   }
// }