Code Samples

Transaction Code Samples

CreateTransactions()

Also see Creating a Simple Transaction for a more in-depth explanation of creating Transactions.

var taskList = new List<object> { new TaskInsertModel() };
var req = new TransactionCreateRequestModel()
{
    EnableLogging = false,
    ResponseIncludes = new TransactionIncludesModel()
    {
        IncludeParticipants = true,
    },
    Transactions = new List<object>
    {
        new TransactionCreateModel()
        {
            IsTest = true,
            ProntoID = "Default",
            Description = "Web Services Insert Test",
            Participants = new List<object>
            {
                new ParticipantInsertModel()
                {
                    FullName = "John Smith",
                    EmailAddress = "john.smith@your-domain.com",
                    SendRequestViaEmail = true,
                    Tasks = taskList
                }
            },
            Documents = new List<object>
            {
                new DocumentInsertModel()
                {
                    Title = "Web Services Insert Test Document",
                    Source = new SourceModel()
                    {
                        FileBytes = System.IO.File.ReadAllBytes(@"c:\myDocument.pdf")
                    },
                    Tasks = taskList
                }
            }
        }
    }
};

var api = new TransactionsApi(myRestEndpointUrl);
var results = api.CreateTransactions(req, apiKey, apiSecret, apiUsername, apiPassword);;
if (results.IsSuccessful.Value)
{
    //do work...
}
else
{
    //handle error
}

GetTransactions()

var req = new TransactionDetailsRequestModel()
{
    EnableLogging = false,
    IDs = new List<object> { 1234567890 },
    Includes = new TransactionIncludesModel()
    {
        IncludeDocuments = true,
        IncludeMetaData = true,
        IncludeParticipants = true,
        IncludeWorkflowActions = true,
        DocumentIncludes = new DocumentIncludesModel()
        {
            IncludeMetaData = true,
            IncludeTasks = true,
            IncludeWorkflowActions = true,
            TaskIncludes = new TaskIncludesModel()
            {
                IncludeFileAttachments = true,
                IncludeWorkflowActions = true
            }
        },
        ParticipantIncludes = new ParticipantIncludesModel()
        {
            IncludeEmailNotifications = true,
            IncludeEmailTemplatePlaceholders = true,
            IncludeWorkflowActions = true
        }
    }
};

var api = new TransactionsApi(myRestEndpointUrl);
var results = api.GetTransactions(req, apiKey, apiSecret, apiUsername, apiPassword);
if (results.IsSuccessful.Value)
{
    //do work...
}
else
{
    //handle error
}

GetTransactionsUpdateable()

var req = new TransactionUpdateableRequestModel()
{
    IDs = new List<object> { 1234567890 }
};

var api = new TransactionsUpdateableApi(myRestEndpointUrl);
var results = api.GetTransactionsUpdateable(req, apiKey, apiSecret, apiUsername, apiPassword);
if (results.IsSuccessful.Value)
{
    //do work...
}
else
{
    //handle error
}

UpdateTransactions()

var req = new TransactionUpdateableRequestModel()
{
    IDs = new List<object> { 1234567890 }
};

var api = new TransactionsUpdateableApi(myRestEndpointUrl);
var results = api.GetTransactionsUpdateable(req, apiKey, apiSecret, apiUsername, apiPassword);
if (results.IsSuccessful.Value)
{
    results.UpdateableTransactions[0].Description = "UPDATED!";
    var updateModel = new TransactionUpdateRequestModel()
    {
        Transactions = results.UpdateableTransactions
    }

    var api = new TransactionsApi(myRestEndpointUrl);
    var updateResults = api.UpdateTransactions(sa, updateModel);
    if (updateResults.IsSuccessful)
    {
        //do work...
    }
    else
    {
        //handle error
    }
}
else
{
    //handle error
}

CloseTransactions()

Also see Cancelling a Transaction for a more in-depth explanation of cancelling transactions.

var req = new TransactionCloseRequestModel()
{
    IDs = new List<object> { 1234567890 }
};

var api = new TransactionsApi(myRestEndpointUrl);
var results = api.CloseTransactions(req, apiKey, apiSecret, apiUsername, apiPassword);
if (results.IsSuccessful.Value)
{
    //do work...
}
else
{
    //handle error
}

GetTransactionTokenData()

Also see Securing Workflow Actions for more information on Security Token usage.

private TransactionTokenDataModel GetSecurityTokenData()
{
    var token = Request.QueryString["ps_securitytoken"];

    var req = new TransactionTokenDataRequestModel();
    req.SecurityToken = token;
    var results = sc.GetTransactionTokenData(sa,req);
    if (results.IsSuccessful.Value)
    {
        return results.TokenData;
    }
    else
    {
        //Handle error
    }
}

Error Codes

s00 - Expected information not provided.s01 - no signature ID provided on the call to SignADoc.s02 - can't create required object - (Server.CreateObject failed).s03 - document status is "signature operation pending".s04 - document is closed for signing (status >= 4).s05 - document status can't be determined.s06 - signature status is "signature operation pending".s07 - signature is closed for signing (status >= 4).s08 - signature status can't be determined.s09 - an error occurred during the signing operation.s10 - the signing function returned FAILURE or ERROR - ErrMsg returned.s11 - database error.s12 - can't determine next step.s13 - can't read file.s14 - invalid parameters used in this request.s15 - image file cannot be saved.s21 - The document is not yet ready for signature.s22 - The document is currently being signed by another party. Please try again in a minute.s23 - The document has already been signed for this signer. It may not be re-signed.s24 - This transaction has been closed. The document may not be signed.s25 - This transaction has been cancelled. The document may not be signed.s26 - This transaction has expired. The document may not be signed.s27 - This signature request has an unknown status - the document may not be signed.s28 - The signature image submitted was blank or empty.s29 - Form data could not be saved.s30 - No client (signer) digital certificate was available for signing.s31 - Client digital certificate use (signing) was cancelled by the user.s32 - User session timeout.s33 - User authentication timeout/login error.s34 - The Instance ID of this application could not be determined.

Workflows-Related Code Samples

Code samples for workflow-related operations in AlphaTrust e-Sign.