Docusign .NET Sdk创建文档并获取收件人视图(嵌入式签名)(ACCOUNT_NOT_AUTHORIZED_FOR_ENVELOPE)

时间:2015-05-29 13:12:19

标签: docusignapi

我正在尝试创建信封并获取收件人网址以供进一步处理。 但总是得到休息错误" ACCOUNT_NOT_AUTHORIZED_FOR_ENVELOPE"。

        string RecipientEmail = "123@123.com";
        string RecipientName = "123";
        string AccountEmail = "myuser@mydomain.com";
        string AccountPassword = "mypassword";
        string documentPath = @"C:\Users\...."; ;

        var account = new Account();
        account.Email = AccountEmail;
        account.Password = AccountPassword;   
        var result = account.Login();
        if (!result)
        return;

        var envelope = new Envelope();
        envelope.Login = account;
        envelope.Recipients = new Recipients()
        {
            signers = new []
            {
                new Signer()
                {
                    email = RecipientEmail,
                    name = RecipientName,
                    recipientId = "1",
                    clientUserId = "777"
                }
            }
        };
        rsult = envelope.Create(documentPath);
        if(!result)return;
        result = envelope.GetRecipientView("mydomain");

REST API

这里是代码示例:
github.com/kosmur/DocuSignTestWithProblems

2 个答案:

答案 0 :(得分:1)

您无法使用API​​使用免费试用帐户(通过www.docusign.com创建)。您需要使用通过DocuSign开发人员中心创建的免费开发人员沙箱

https://www.docusign.com/devcenter

此外,我不相信您正在遵循嵌入式签名流程的正确模式。您需要先创建信封(即DocuSign服务器端),然后才能请求签名URL。我在你的GitHub代码中看到你正在实例化一个信封对象,但我没有看到实际创建一个信封的调用。

如果您查看DocuSign .NET Client根级别的Examples.cs并向下滚动到示例#8 ,您会看到它如何引用现有信封,即

    //==========================================================================================
    // *** Walkthrough #8 - Embedded Signing
    //==========================================================================================
    private void EmbeddedSigning()
    {
        //*****************************************************************
        // ENTER VALUES FOR FOLLOWING VARIABLES!
        //*****************************************************************
        string AccountEmail = "***";
        string AccountPassword = "***";
        string EnvelopeId = "***";
        string RecipientEmail = "***";
        string RecipientName = "***";
        //*****************************************************************

        // user credentials 
        Account account = new Account();
        account.Email = AccountEmail;
        account.Password = AccountPassword;

        // make the login call (retrieves your baseUrl and accountId)
        bool result = account.Login();
        if (!result)
        {
            Console.WriteLine("Login API call failed for user {0}.\nError Code:  {1}\nMessage:  {2}", account.Email, account.RestError.errorCode, account.RestError.message);
            return;
        }

        // create envelope object and assign login info
        Envelope envelope = new Envelope();
        envelope.Login = account;

        // assign the envelope id that was passed in
        envelope.EnvelopeId = EnvelopeId;

        // add one signer (single recipient embedded signing currently supported in DocuSign .NET Client)
        envelope.Recipients = new Recipients()
        {
            signers = new Signer[]
            {
                new Signer()
                {
                    email = RecipientEmail,
                    name = RecipientName,
                    recipientId = "1"
                }
            }
        };

        // generate the recipient view token
        result = envelope.GetRecipientView("http://www.nuget.org/packages/DocuSign.Integration.Client.dll/");

        if (!result)
        {
            if (envelope.RestError != null)
            {
                Console.WriteLine("Error code:  {0}\nMessage:  {1}", envelope.RestError.errorCode, envelope.RestError.message);
                return;
            }
            else
            {
                Console.WriteLine("Error encountered retrieving signing token, please review your envelope and recipient data.");
                return;
            }
        }
        else
        {
            // open the recipient view (SenderViewUrl field is re-used for the recipient URL)
            Process.Start(envelope.SenderViewUrl);
        }
    }

答案 1 :(得分:0)

用户应该通过自定义" X-DocuSign-Authentication"每个docusign调用带有bearer docusign标记的头或授权标头。