Skip to main content
Blog
Home/

Trending Topics: Latest from our forums (July 2020)

Author Inbar Gazit
Inbar GazitSr. Manager, Developer Content
Summary3 min read

Error 400 on generating recipient views, getting an access token using Visual Basic .NET, and understanding error messages for expired refresh tokens.

    • Additional resources

    Table of contents

    Trending Topics

    Here are some of the latest popular questions that the Docusign developers community asked on Stack Overflow in the month of July 2020. You too can ask questions by using the tag docusignapi in Stack Overflow.

    Thread: Signer URL for an envelope - calling docusign API and getting 400 bad request error

    Summary: The developer is trying to generate a recipient view to embed inside their application. They are getting a 400 error wherein the Docusign eSignature REST API reports a “bad request message.” 

    Answer: There are two ways to use embedded signing. In one case, you want to send the envelope to a user that already has a membership in a Docusign account. In that case, you need to provide their APIUserId, which is a unique identifier (GUID) that corresponds to their user. This has to be provided in the clientUserId parameter, but the information for the recipient (email and name) must also match exactly what is stored for that user in Docusign. In the second case, you can use a user that has no membership in a Docusign account and just provide any string for the clientUserID, so long as it’s unique for this envelope. The recipientID must also match between the envelope definition and the request for an embedded signing view.

    Thread: Docusign JWT Access Token Request

    Summary: The developer is attempting to use JWT authentication using Visual Basic.NET and the Docusign.eSign.dll (SDK) to obtain an access token. Using the SDK method is not working, so they have to call the API directly and are running into issues.

    Answer: Encoding the private RSA key using Visual Basic may be a bit tricky. Here is a working VS code that the developer was able to use:

    Dim PrivateKey As String = "MIIEowIBAAKCAQEAjtTe7UUP/CBI9s……......JfwZ2hHqFPXA9ecbhc0".Replace(vbLf, "").Replace(vbCr, "") 
    Dim ar1 As JObject = New JObject() 
    ar1.Add("typ", "JWT") ar1.Add("alg", "RS256") 
    Dim header As String = Base64UrlEncoder.Encode(ar1.ToString) 
    Dim ar2 As JObject = New JObject() 
    ar2.Add("iss", "INTEGRATION_ID") 
    ar2.Add("sub", "GUID_VERSION_OF_USER_ID") 
    ar2.Add("iat", DateDiff(DateInterval.Second, New Date(1970, 1, 1), Now().ToUniversalTime)) 
    ar2.Add("exp", DateDiff(DateInterval.Second, New Date(1970, 1, 1), DateAdd(DateInterval.Hour, 1, Now().ToUniversalTime))) 
    ar2.Add("aud", "account-d.docusign.com") ar2.Add("scope", "signature") 
    Dim body As String = Base64UrlEncoder.Encode(ar2.ToString) 
    Dim stringToSign As String = header & "." & body 
    Dim bytesToSign() As Byte = Encoding.UTF8.GetBytes(stringToSign) 
    Dim keyBytes() As Byte = Convert.FromBase64String(PrivateKey) Dim privKeyObj = Asn1Object.FromByteArray(keyBytes) 
    Dim privStruct = RsaPrivateKeyStructure.GetInstance(privKeyObj) 
    Dim sig As ISigner = SignerUtilities.GetSigner("SHA256withRSA") 
    sig.Init(True, New RsaKeyParameters(True, privStruct.Modulus, privStruct.PrivateExponent)) 
    sig.BlockUpdate(bytesToSign, 0, bytesToSign.Length) 
    Dim signature() As Byte = sig.GenerateSignature() 
    Dim sign As String = Base64UrlEncoder.Encode(signature) 
    Return header & "." & body & "." & sign
    

    Additional resources

    Author Inbar Gazit
    Inbar GazitSr. Manager, Developer Content

    Inbar Gazit has been with Docusign since 2013 in various engineering roles. Since 2019 he has focused on developer content. Inbar works on code examples including the launchers, available on GitHub in eight languages, and helps build sample apps showcasing the various Docusign APIs. He is also active on StackOverflow, answering your questions. Inbar can be reached at inbar.gazit@docusign.com.

    More posts from this author

    Related posts

    • How to fix duplicate tabs in Docusign: Anchor vs. custom tabs
      Developers

      How to fix duplicate tabs in Docusign: Anchor vs. custom tabs

      Author Sai Dandamudi
      Sai Dandamudi
    • Enhancing Sales Success with Strategic Insights from Salesforce and Docusign AI

      Enhancing Sales Success with Strategic Insights from Salesforce and Docusign AI

      Author Subbarao Pydikondala
      Subbarao Pydikondala
    • From the Trenches: Automating JWT OAuth in Insomnia

      From the Trenches: Automating JWT OAuth in Insomnia

      Author Robert Schendle
      Robert Schendle
    How to fix duplicate tabs in Docusign: Anchor vs. custom tabs

    How to fix duplicate tabs in Docusign: Anchor vs. custom tabs

    Author Sai Dandamudi
    Sai Dandamudi
    Enhancing Sales Success with Strategic Insights from Salesforce and Docusign AI

    Enhancing Sales Success with Strategic Insights from Salesforce and Docusign AI

    Author Subbarao Pydikondala
    Subbarao Pydikondala
    From the Trenches: Automating JWT OAuth in Insomnia

    From the Trenches: Automating JWT OAuth in Insomnia

    Author Robert Schendle
    Robert Schendle

    Discover what's new with Docusign IAM or start with eSignature for free

    Explore Docusign IAMTry eSignature for Free
    Person smiling while presenting