Пакет DocuSignAPI nuget c # REST: вкладки UpdateRecipients & UpdateDocuments не добавляются при добавлении нового документа в существующий конверт - PullRequest
0 голосов
/ 08 июня 2018

Я использую пакет nuget c # REST.Когда я пытаюсь добавить документ с новыми получателями в существующий конверт, получатели и документ отображаются в конверте, но нет никаких вкладок, связанных с новым документом, даже если вкладки перечислены для новых получателей, когда я вызываю UpdateRecipients.

Я проверил, чтобы убедиться, что DocID совпадает на вкладках с новым DocID, отправленным в EnvelopeDefinition для UpdateDocuments, и все остальные данные кажутся правильными, но для новых получателей вкладки не отображаются.

Я пробовал это, передавая только 2 новых получателя или передавая весь список получателей (3 предыдущих + 2 новых).В обоих случаях все получатели возвращают сообщение об успехе от UpdateRecipients, но вкладки не добавляются.

Вот часть моего кода.

            EnvelopeDefinition envDef = new EnvelopeDefinition();
            envDef.Documents = new List<Document>();

            foreach (DSDocumentIN docIN in documents)
            {

                // Add a document to the envelope
                Document doc = new Document();
                doc.Name = docIN.Name;
                doc.DocumentBase64 = docIN.FileBase64;
                doc.DocumentId = docIN.DocID;

                envDef.Documents.Add(doc);
            }

            int iCounter = 1;

            List<Signer> signerList = new List<Signer>();

            List<DSSigner> fullSignerList = new List<DSSigner>();
            fullSignerList = GetDSSigners(existingEnvelopeId);
            foreach (DSSigner newSigner in signers)
            {
                fullSignerList.Add(newSigner);
            }

            foreach (DSSigner s in fullSignerList)
            {
                Signer docSigner = new Signer();
                docSigner.Email = s.Email;
                docSigner.Name = s.FirstName + " " + s.LastName;
                docSigner.RoleName = s.Role;
                if (string.IsNullOrEmpty(s.RecipientId))
                    docSigner.RecipientId = Guid.NewGuid().ToString();
                else
                    docSigner.RecipientId = s.RecipientId;
                if (string.IsNullOrEmpty(s.RoutingOrder))
                    docSigner.RoutingOrder = iCounter.ToString();
                else
                    docSigner.RoutingOrder = s.RoutingOrder;
                if (string.IsNullOrEmpty(s.State))
                    docSigner.Status = "Created";
                else
                    docSigner.Status = s.State;


                docSigner.Tabs = AllTabs(docSigner, documents);

                signerList.Add(docSigner);
                iCounter++;
            }

            envDef.Recipients = new Recipients();
            envDef.Recipients.Signers = new List<Signer>();
            envDef.Recipients.Signers = signerList;

            RecipientsUpdateSummary recipientsUpdateSummary = apiInstance.UpdateRecipients(accountId, existingEnvelopeId, envDef.Recipients);


            EnvelopesApi.UpdateDocumentsOptions UpdateDocOptions = new EnvelopesApi.UpdateDocumentsOptions();
            UpdateDocOptions.applyDocumentFields = "True";  // string | When true, Document fields can be added or modified while adding or modifying envelope documents. (optional)  

            // Adds one or more documents to an existing envelope document.
            EnvelopeDocumentsResult result = apiInstance.UpdateDocuments(accountId, existingEnvelopeId, envDef, UpdateDocOptions);
            Debug.WriteLine(result);

            //Get recipients to find RecipientIdGuid (which becomes RecipientId when sending). RecipientId is key field in db. -- DocuSign does not appear to have this RecipientIdGuid/RecipientId documented
            Recipients recips = apiInstance.ListRecipients(accountId, existingEnvelopeId);

06/12/18 ОБНОВЛЕНИЕ: В настоящее время яЯ добавляю новый документ, а затем получателей.Для этого подхода я включил ссылку на журналы: Журнал DocuSign

(см. Конкретно 04_OK_AddDocumentsToEnvelope.txt & 03_OK_UpdateEnvelopeRecipients.txt)

Ответы [ 2 ]

0 голосов
/ 13 июня 2018

Мне кажется, я понял это.

Собираюсь почистить его и убедиться, что он работает как нужно, а затем я опубликую более подробную информацию здесь.

06/13 /ОБНОВЛЕНИЕ 2018:
Этот ответ специально для использования пакета nuget c # REST.Поскольку вкладки являются частью объекта «Получатель», я ожидал, что включение вкладок в объект получателя и добавление получателя в конверт будет работать.Однако это не тот случай, когда вызывается метод UpdateRecipients.Новые получатели добавляются, но нет новых вкладок.Вместо этого вкладки должны быть добавлены отдельно.

Также интересно было назвать имена функций, которые должны были быть вызваны следующим образом:
Добавить новый документ = UpdateDocuments
Добавить новых получателей = UpdateRecipients
Добавитьновые вкладки = Создать Вкладки

Возможно, есть другие способы, которые работают, но вот суть кода, который работает для меня:

    public string AddDocumentsToEnvelope(List<DSDocumentIN> documents, List<DSSigner> signers, string clientAppNo, int PDFRequestID, string envelopeID)
    {

        string username = "randys@balboacapital.com";
        string password = "555Tmppwd";
        string integratorKey = "321e15cb-89a1-4958-a444-6b2d33fc7005";


        string retEnvelopeID = "";
        ExceptionDispatchInfo exInfo = null;

        try
        {

            var pdfDocCtrl = new BalboaLeaseCL.PDFDocController();
            var apiInstance = new EnvelopesApi();

            string existingEnvelopeId = envelopeID;

            // initialize client for desired environment (for production change to www)
            ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
            Configuration.Default.ApiClient = apiClient;

            // configure 'X-DocuSign-Authentication' header
            string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // we will retrieve this from the login API call
            string accountId = null;

            /////////////////////////////////////////////////////////////////
            // STEP 1: LOGIN API        
            /////////////////////////////////////////////////////////////////

            // login call is available in the authentication api 
            AuthenticationApi authApi = new AuthenticationApi();
            LoginInformation loginInfo = authApi.Login();

            // parse the first account ID that is returned (user might belong to multiple accounts)
            accountId = loginInfo.LoginAccounts[0].AccountId;

            // Update ApiClient with the new base url from login call
            string[] separatingStrings = { "/v2" };
            apiClient = new ApiClient(loginInfo.LoginAccounts[0].BaseUrl.Split(separatingStrings, StringSplitOptions.RemoveEmptyEntries)[0]);

            EnvelopeDefinition envDef = new EnvelopeDefinition();
            envDef.Documents = new List<Document>();

            foreach (DSDocumentIN docIN in documents)
            {

                // Add a document to the envelope
                Document doc = new Document();
                doc.Name = docIN.Name;
                doc.DocumentBase64 = docIN.FileBase64;
                doc.DocumentId = docIN.DocID;

                envDef.Documents.Add(doc);
            }

            int iCounter = 1;

            List<Signer> signerList = new List<Signer>();

            List<DSSigner> fullSignerList = new List<DSSigner>();
            fullSignerList = GetDSSigners(existingEnvelopeId);

            foreach (DSSigner newSigner in signers)
            {
                fullSignerList.Add(newSigner);
            }

            foreach (DSSigner s in fullSignerList)
            {
                Signer docSigner = new Signer();
                docSigner.Email = s.Email;
                docSigner.Name = s.FirstName + " " + s.LastName;
                docSigner.RoleName = s.Role;
                if (string.IsNullOrEmpty(s.RecipientId))
                    docSigner.RecipientId = Guid.NewGuid().ToString();
                else
                    docSigner.RecipientId = s.RecipientId;
                if (string.IsNullOrEmpty(s.RoutingOrder))
                    docSigner.RoutingOrder = iCounter.ToString();
                else
                    docSigner.RoutingOrder = s.RoutingOrder;
                if (string.IsNullOrEmpty(s.State))
                    docSigner.Status = "Created";
                else
                    docSigner.Status = s.State;


                docSigner.Tabs = AllTabs(docSigner, documents);

                signerList.Add(docSigner);
                iCounter++;
            }

            envDef.Recipients = new Recipients();
            envDef.Recipients.Signers = new List<Signer>();
            envDef.Recipients.Signers = signerList;



            EnvelopesApi.UpdateDocumentsOptions UpdateDocOptions = new EnvelopesApi.UpdateDocumentsOptions();
            UpdateDocOptions.applyDocumentFields = "True";  // string | When true, Document fields can be added or modified while adding or modifying envelope documents. (optional)  

            // Adds one or more documents to an existing envelope 
            EnvelopeDocumentsResult result = apiInstance.UpdateDocuments(accountId, existingEnvelopeId, envDef, UpdateDocOptions);

            if (string.IsNullOrEmpty(result.EnvelopeId))
                throw new DocuSignAPIException("No EnvelopeID returned.");
            else
                retEnvelopeID = result.EnvelopeId;

            //Adds recipients to envelope (but won't create tabs)
            RecipientsUpdateSummary recipientsUpdateSummary = apiInstance.UpdateRecipients(accountId, existingEnvelopeId, envDef.Recipients);



            foreach (DSSigner newSigner in signers)
            {
                foreach (Signer s in envDef.Recipients.Signers)
                {
                    if (newSigner.RecipientId.Equals(s.RecipientId, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //Adds the tabs for the recipients for the new doc
                        apiInstance.CreateTabs(accountId, existingEnvelopeId, s.RecipientId, s.Tabs);
                        break;
                    }
                }
            }
0 голосов
/ 12 июня 2018

После того, как вы создали конверт, вам нужно сделать вызовы ниже, чтобы добавить документ и получателей с правильными вкладками в документе, у меня есть только пример кода JSON, не могу проверить с кодом CSharp, но вы точно знаете вызовдля того же самого:

Чтобы добавить документ, позвоните ниже конечной точки,

нет необходимости добавлять получателей в этот вызов, просто добавьте документ

PUT /restapi/v2/accounts/{accountId}/envelopes/{envelopeId}/documents/2

с ниже заголовки:

Accept:application/json
Authorization:Bearer <AccessToken>
Content-Type:application/pdf
Content-Disposition:file; filename="Cross Company Guaranty"; fileExtension=pdf; documentId=2
Content-Transfer-Encoding:base64

Тело:

base64bytes

Оба UpdateDocuments() и UpdateDocument() могут добавить документ в конверт.

Чтобы добавить получателей и их вкладки, вам нужно позвонить ниже конечной точки,

вместо EnvelopeRecipients: update , должно быть Envelopes: update с параметром запроса advanced_update=true

PUT / restapi / v2 / accounts / {accountId} / envelopes / {envelopeId}? advanced_update = true

Тело:

{
"recipients": {
    "signers": [{
        "email": "FakeTempEmailAddressRequired@bccfaketemp.com",
        "name": "Mary GS",
        "recipientId": "78647ecb-ee2e-4910-92ef-c9bf18710657",
        "roleName": "Guarantor_Signor",
        "routingOrder": "4",
        "status": "Created",
        "tabs": {
            "dateSignedTabs": [],
            "initialHereTabs": [],
            "signHereTabs": [{
                "documentId": "2",
                "optional": "false",
                "pageNumber": "1",
                "recipientId": "78647ecb-ee2e-4910-92ef-c9bf18710657",
                "scaleValue": "0.9",
                "tabOrder": "2",
                "xPosition": "60",
                "yPosition": "343"
            }],
            "textTabs": [{
                "disableAutoSize": "true",
                "documentId": "2",
                "fontSize": "Size8",
                "height": 10,
                "pageNumber": "1",
                "recipientId": "78647ecb-ee2e-4910-92ef-c9bf18710657",
                "required": "true",
                "tabLabel": "SealDate",
                "tabOrder": "1",
                "validationMessage": "Please enter valid date using \"mm/dd/yyyy\" format",
                "validationPattern": "^((0?[1-9]|1[012])[/](0?[1-9]|[12][0-9]|3[01])[/]?[0-9]{4})*$",
                "width": 100,
                "xPosition": "248",
                "yPosition": "319"
            },
            {
                "disableAutoSize": "true",
                "documentId": "2",
                "fontSize": "Size8",
                "height": 10,
                "pageNumber": "1",
                "recipientId": "78647ecb-ee2e-4910-92ef-c9bf18710657",
                "required": "true",
                "tabLabel": "Guarantor_SignorTitle",
                "tabOrder": "3",
                "validationMessage": "",
                "validationPattern": "",
                "width": 210,
                "xPosition": "71",
                "yPosition": "408"
            },
            {
                "disableAutoSize": "true",
                "documentId": "2",
                "fontSize": "Size8",
                "height": 10,
                "pageNumber": "1",
                "recipientId": "78647ecb-ee2e-4910-92ef-c9bf18710657",
                "required": "true",
                "tabLabel": "Guarantor_SignorTitle",
                "tabOrder": "4",
                "validationMessage": "",
                "validationPattern": "",
                "width": 210,
                "xPosition": "114",
                "yPosition": "522"
            }]
        }
    },
    {
        "email": "FakeTempEmailAddressRequired@bccfaketemp.com",
        "name": "Tony GW",
        "recipientId": "259e95e8-b774-47c1-b2dd-acab0d3b965e",
        "roleName": "GuarantorWitness",
        "routingOrder": "5",
        "status": "Created",
        "tabs": {
            "dateSignedTabs": [{
                "documentId": "2",
                "fontSize": "Size8",
                "pageNumber": "1",
                "recipientId": "259e95e8-b774-47c1-b2dd-acab0d3b965e",
                "tabOrder": "4",
                "xPosition": "80",
                "yPosition": "660"
            }],
            "initialHereTabs": [],
            "signHereTabs": [{
                "documentId": "2",
                "optional": "false",
                "pageNumber": "1",
                "recipientId": "259e95e8-b774-47c1-b2dd-acab0d3b965e",
                "scaleValue": "0.9",
                "tabOrder": "2",
                "xPosition": "84",
                "yPosition": "579"
            }],
            "textTabs": [{
                "disableAutoSize": "true",
                "documentId": "2",
                "fontSize": "Size8",
                "height": 10,
                "pageNumber": "1",
                "recipientId": "259e95e8-b774-47c1-b2dd-acab0d3b965e",
                "required": "true",
                "tabLabel": "GuarantorWitnessTitle",
                "tabOrder": "1",
                "validationMessage": "",
                "validationPattern": "",
                "width": 200,
                "xPosition": "425",
                "yPosition": "464"
            },
            {
                "disableAutoSize": "true",
                "documentId": "2",
                "fontSize": "Size8",
                "height": 10,
                "pageNumber": "1",
                "recipientId": "259e95e8-b774-47c1-b2dd-acab0d3b965e",
                "required": "true",
                "tabLabel": "GuarantorWitnessTitle",
                "tabOrder": "3",
                "validationMessage": "",
                "validationPattern": "",
                "width": 210,
                "xPosition": "80",
                "yPosition": "645"
            }]
        }
    }]
    }
}

Update метод должен работать, но обязательно передайте / установите advancedUpdate как true в UpdateOptions параметры

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...