简体   繁体   中英

Docusign Move Envelope using C# - How can I turn XML/JSON requests and “PUT” methods into working C# code?

First, my code:

    string accountID = loginInfo.LoginAccounts[0].AccountId;

        Console.WriteLine("Account ID:" + accountID);
        FoldersApi foldApi = new FoldersApi();
        var folders = foldApi.List(accountID);
        //this is pointing to my "Sent" folder
        string folderID = folders.Folders[1].FolderId;
        var envID = foldApi.ListItems(accountID, folderID);

        foreach (FolderItem fi in envID.FolderItems)
        {
            EnvelopesApi envApi = new EnvelopesApi();

            EnvelopeDocumentsResult docsList = envApi.ListDocuments(accountID, fi.EnvelopeId);
            Recipients listRecip = envApi.ListRecipients(accountID, fi.EnvelopeId);
            string listOfInfo = "";
            Envelope myEnv = envApi.GetEnvelope(accountID, fi.EnvelopeId);
            if (myEnv.Status == "completed")
            {
                foreach (var signer in listRecip.Signers)
                {
                    var listTabs = envApi.ListTabs(accountID, fi.EnvelopeId, signer.RecipientId);
                    foreach (var tab in listTabs.TextTabs)
                    {
                        //listOfInfo is for each specific document, just to view results
                        listOfInfo += tab.TabLabel + " - " + tab.Value + " \n ";
                        //bigString is an aggregation of all documents tab values
                        bigString += tab.TabLabel + " - " + tab.Value + " \n ";
                    }
                    Console.WriteLine("Stop here");//breakpoint
                }
                //Move code should go here.
            }
        }

Currently my code enters into my account, gets a list of all the folders, and I then point towards my "Sent" folder. After that, I look at all of the documents in the sent folder, check if their status is "completed", and when it is, go "into" that document and strip out all of the information living in the texttabs I've placed on a document.

Onto my question! Where the comment "//Move code should go here." after I have stripped out my needed information, I would like to move an envelope from my "Sent" folder (Folders[1]) and place it into my "Loaded" folder (Folders[3]).

I have reviewed : https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Move%20Envelope.htm

but I am unable to make sense of how to turn XML/JSON requests and "PUT" methods into working C# code.

Any assistance would be greatly appreciated. Thanks,

-Kyle.

Updated Code.

        Console.WriteLine("Account ID:" + accountID);
        FoldersApi foldApi = new FoldersApi();
        //create fr object
        FoldersRequest fr = new FoldersRequest();
        //instantiate EnvelopeIds string list, to a new string list..
        fr.EnvelopeIds = new List<string>();
        //get folders
        var folders = foldApi.List(accountID);
        string sentFolderID = "";
        string loadedFolderID = "";
        foreach (var fold in folders.Folders)
        {//get sent/loaded folder IDs
            if (fold.Name == "Sent Items") { sentFolderID = fold.FolderId; }
            else if(fold.Name == "Loaded") { loadedFolderID = fold.FolderId; }
        }
        //list the items in the folder
        var envID = foldApi.ListItems(accountID, sentFolderID);
        //for each item in the folder...
        foreach (FolderItem fi in envID.FolderItems)
        {
            EnvelopesApi envApi = new EnvelopesApi();
            //get a list of documents in the envelope
            EnvelopeDocumentsResult docsList = envApi.ListDocuments(accountID, fi.EnvelopeId);
            //list recipients
            Recipients listRecip = envApi.ListRecipients(accountID, fi.EnvelopeId);
            string listOfInfo = "";
            Envelope myEnv = envApi.GetEnvelope(accountID, fi.EnvelopeId);
            if (myEnv.Status == "completed")
            {
                foreach (var signer in listRecip.Signers)
                {
                    var listTabs = envApi.ListTabs(accountID, fi.EnvelopeId, signer.RecipientId);
                    foreach (var tab in listTabs.TextTabs)
                    {
                        //get info out of document
                        listOfInfo += tab.TabLabel + " - " + tab.Value + " \n ";
                        bigString += tab.TabLabel + " - " + tab.Value + " \n ";
                    }
                    Console.WriteLine("Stop here");//breakpoint
                }
                //add this envelope ID to the list of envelopes to be moved
                fr.EnvelopeIds.Add(myEnv.EnvelopeId);                    
            }
        }
        //move all the envelopes in the list
        if (fr.EnvelopeIds.Count >= 1) { foldApi.MoveEnvelopes(accountID, loadedFolderID, fr); }

I found a solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM