Nate S
Nate S

Reputation: 1

GetEmbeddedSignerView badrequest DocuSign API

I am trying to call the emmbeddedSignerView method from the docusign nuget package but the response fails to return a url. I ended up copying the unit test code

// create a new envelope with 2 recipients            
        var envelope = new Envelope { Login = account };
        byte[] doc1 = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 };
        var signers = new List<Signer>();
        // note we need to specify clientUserId
        signers.Add(new Signer { email = "[email protected]", name = "test1", recipientId = "1", routingOrder = "1", clientUserId = "1" });
        //signers.Add(new Signer { email = "[email protected]", name = "test2", recipientId = "2", routingOrder = "2", clientUserId = "2" });
        envelope.Recipients = new Recipients { signers = signers.ToArray() };
        envelope.Create(doc1, "test-self-signed.doc");

        // send it
        envelope.Status = "sent";
        envelope.UpdateStatus();

        // get embedded signing views for 2 recipients
        string urlForfirstSigner = envelope.GetEmbeddedSignerView("www.docusign.com", signers.First());

When I debug I can see that the response status code is "BadRequest" with the response text "RECIPIENT_NOT_IN_SEQUENCE\",\r\n \"message\": \"The token for an out of sequence recipient cannot be generated."

Am I doing something wrong? I figured since I copied the code it should work...

I am using the nuget package so I copied the object data of my create and embedded signing requests and responses hopefully this will help.

REQUEST
{System.Net.HttpWebRequest}
    base: {System.Net.HttpWebRequest}
    Accept: null
    Address: {https://demo.docusign.net/restapi/v2/accounts/991023/envelopes?api_password=true}
    AllowAutoRedirect: true
    AllowReadStreamBuffering: false
    AllowWriteStreamBuffering: true
    AutomaticDecompression: None
    ClientCertificates: {System.Security.Cryptography.X509Certificates.X509CertificateCollection}
    Connection: null
    ConnectionGroupName: null
    ContentLength: 512
    ContentType: "multipart/form-data; boundary=00000000-0000-0000-0000-000000000000"
    ContinueDelegate: null
    ContinueTimeout: 350
    CookieContainer: null
    Credentials: null
    Date: {1/1/0001 12:00:00 AM}
    Expect: null
    HaveResponse: false
    Headers: {X-DocuSign-Authentication: <DocuSignCredentials><Username>[email protected]</Username><Password>MYPASSWORD</Password><IntegratorKey>MYINTEGRATORKEY</IntegratorKey></DocuSignCredentials>
Content-Type: multipart/form-data; boundary=00000000-0000-0000-0000-000000000000
Host: demo.docusign.net

}
    Host: "demo.docusign.net"
    IfModifiedSince: {1/1/0001 12:00:00 AM}
    KeepAlive: true
    MaximumAutomaticRedirections: 50
    MaximumResponseHeadersLength: 64
    MediaType: null
    Method: "POST"
    Pipelined: true
    PreAuthenticate: false
    ProtocolVersion: {1.1}
    Proxy: null
    ReadWriteTimeout: 300000
    Referer: null
    RequestUri: {https://demo.docusign.net/restapi/v2/accounts/991023/envelopes?api_password=true}
    SendChunked: false
    ServerCertificateValidationCallback: null
    ServicePoint: {System.Net.ServicePoint}
    SupportsCookieContainer: true
    Timeout: 100000
    TransferEncoding: null
    UnsafeAuthenticatedConnectionSharing: false
    UseDefaultCredentials: false
    UserAgent: null



RESPONSE

{DocuSign.Integrations.Client.ResponseInfo}
    ContentType: "application/json; charset=utf-8"
    ErrorMessage: ""
    ResponseBytes: {byte[198]}
    ResponseStream: {System.Net.ConnectStream}
    ResponseText: "{\r\n  \"envelopeId\": \"b3c02285-f787-49b4-951d-53bb4057023e\",\r\n  \"uri\": \"/envelopes/b3c02285-f787-49b4-951d-53bb4057023e\",\r\n  \"statusDateTime\": \"2015-04-22T04:26:41.7770000Z\",\r\n  \"status\": \"created\"\r\n}"
    StatusCode: Created


REQUEST
{System.Net.HttpWebRequest}
    base: {System.Net.HttpWebRequest}
    Accept: "application/json"
    Address: {https://demo.docusign.net/restapi/v2/accounts/991023/envelopes/b3c02285-f787-49b4-951d-53bb4057023e/views/recipient}
    AllowAutoRedirect: true
    AllowReadStreamBuffering: false
    AllowWriteStreamBuffering: true
    AutomaticDecompression: None
    ClientCertificates: {System.Security.Cryptography.X509Certificates.X509CertificateCollection}
    Connection: null
    ConnectionGroupName: null
    ContentLength: 133
    ContentType: "application/json"
    ContinueDelegate: null
    ContinueTimeout: 350
    CookieContainer: null
    Credentials: null
    Date: {1/1/0001 12:00:00 AM}
    Expect: null
    HaveResponse: false
    Headers: {Accept: application/json
Content-Type: application/json
X-DocuSign-Authentication: <DocuSignCredentials><Username>[email protected]</Username><Password>MYPASSWORD</Password><IntegratorKey>MYINTEGRATORKEY</IntegratorKey></DocuSignCredentials>
Host: demo.docusign.net

}
    Host: "demo.docusign.net"
    IfModifiedSince: {1/1/0001 12:00:00 AM}
    KeepAlive: true
    MaximumAutomaticRedirections: 50
    MaximumResponseHeadersLength: 64
    MediaType: null
    Method: "POST"
    Pipelined: true
    PreAuthenticate: false
    ProtocolVersion: {1.1}
    Proxy: null
    ReadWriteTimeout: 300000
    Referer: null
    RequestUri: {https://demo.docusign.net/restapi/v2/accounts/991023/envelopes/b3c02285-f787-49b4-951d-53bb4057023e/views/recipient}
    SendChunked: false
    ServerCertificateValidationCallback: null
    ServicePoint: {System.Net.ServicePoint}
    SupportsCookieContainer: true
    Timeout: 100000
    TransferEncoding: null
    UnsafeAuthenticatedConnectionSharing: false
    UseDefaultCredentials: false
    UserAgent: null

RESPONSE
{DocuSign.Integrations.Client.ResponseInfo}
    ContentType: "application/json; charset=utf-8"
    ErrorMessage: "Bad Request"
    ResponseBytes: null
    ResponseStream: null
    ResponseText: "{\r\n  \"errorCode\": \"RECIPIENT_NOT_IN_SEQUENCE\",\r\n  \"message\": \"The token for an out of sequence recipient cannot be generated.\"\r\n}"
    StatusCode: BadRequest

Upvotes: 0

Views: 627

Answers (1)

Andrew
Andrew

Reputation: 4441

The envelope status above in question is created, you can only pull SignerView when the document is in Sent status and the recipient's routing order is the current one awaiting action.

You don't have your POST content above for your create envelope call, but I'm assuming you're not including 'status':'sent'.

Upvotes: 0

Related Questions