Sample code for 30+ languages & platforms
Node.js

Amazon Voice ID - Describe Domain

See more Amazon Voice ID Examples

Describes the specified domain.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

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

    var rest = new chilkat.Rest();

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

    //  URL: https://voiceid.us-west-2.amazonaws.com/
    var bTls = true;
    var port = 443;
    var bAutoReconnect = true;
    //  Use the same region as specified above.
    success = rest.Connect("voiceid.us-west-2.amazonaws.com",port,bTls,bAutoReconnect);
    if (success !== true) {
        console.log("ConnectFailReason: " + rest.ConnectFailReason);
        console.log(rest.LastErrorText);
        return;
    }

    //  Use this online tool to generate code from sample JSON:
    //  Generate Code to Create JSON

    //  The following JSON is sent in the request body.

    //  {
    //      "DomainId": "<domainId>"
    //  }
    //  

    var json = new chilkat.JsonObject();
    json.UpdateString("DomainId","<domainId>");

    rest.AddHeader("Content-Type","application/x-amz-json-1.0");
    rest.AddHeader("X-Amz-Target","VoiceID.DescribeDomain");
    rest.AddHeader("Accept-Encoding","identity");

    var sbRequestBody = new chilkat.StringBuilder();
    json.EmitSb(sbRequestBody);
    var sbResponseBody = new chilkat.StringBuilder();
    success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    var respStatusCode = rest.ResponseStatusCode;
    console.log("response status code = " + respStatusCode);
    if (respStatusCode !== 200) {
        console.log("Response Status Code = " + respStatusCode);
        console.log("Response Header:");
        console.log(rest.ResponseHeader);
        console.log("Response Body:");
        console.log(sbResponseBody.GetAsString());
        return;
    }

    var jsonResponse = new chilkat.JsonObject();
    jsonResponse.LoadSb(sbResponseBody);

    jsonResponse.EmitCompact = false;
    console.log(jsonResponse.Emit());

    //  If successful, the response status code is 200, and the response syntax:

    //  {
    //     "Domain": { 
    //        "Arn": "string",
    //        "CreatedAt": number,
    //        "Description": "string",
    //        "DomainId": "string",
    //        "DomainStatus": "string",
    //        "Name": "string",
    //        "ServerSideEncryptionConfiguration": { 
    //           "KmsKeyId": "string"
    //        },
    //        "UpdatedAt": number
    //     }
    //  }

    var DomainArn = jsonResponse.StringOf("Domain.Arn");
    var DomainCreatedAt = jsonResponse.IntOf("Domain.CreatedAt");
    var DomainDescription = jsonResponse.StringOf("Domain.Description");
    var DomainDomainId = jsonResponse.StringOf("Domain.DomainId");
    var DomainDomainStatus = jsonResponse.StringOf("Domain.DomainStatus");
    var DomainName = jsonResponse.StringOf("Domain.Name");
    var DomainServerSideEncryptionConfigurationKmsKeyId = jsonResponse.StringOf("Domain.ServerSideEncryptionConfiguration.KmsKeyId");
    var DomainUpdatedAt = jsonResponse.IntOf("Domain.UpdatedAt");

}

chilkatExample();