PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 26, 2022

[FIXED] How Call DocuSign to create the envelope in production?

 August 26, 2022     docusignapi, vb.net     No comments   

Issue

I am trying to call DocuSign to create the envelope in production and I am getting error as

 Error calling CreateEnvelope: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>

Code to call envelope

    Dim accessToken = AccessToken1 ' Access token using JWT
    Dim basePath = BasePath1 ' https://eu.docusign.net/restapi
    Dim accountId = AccountId1 ' AccountId1 from production login
    Dim env As EnvelopeDefinition = MakeEnvelope(Signer, DocusignCcAddress, Buffer, FileName)
   
    Dim apiClient = New ApiClient(basePath)
    apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " & accessToken)
    Dim envelopesApi As EnvelopesApi = New EnvelopesApi(apiClient)
    Dim results As EnvelopeSummary = envelopesApi.CreateEnvelope(accountId, env) ' here i get that error
    Return results

When U use basepath URL as "https://docusign.net/restapi" I am getting this error

Error calling CreateEnvelope: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

I used following code to get access token successfully

        Dim apiClient = New ApiClient("https://eu.docusign.net/restapi")
        Dim ik As String = odjDTRep.Rows(0)("iss_Int_Key").ToString()
        Dim userId As String = odjDTRep.Rows(0)("sub1_Api_UserName").ToString()

        Dim authserver As String = odjDTRep.Rows(0)("aud").ToString()
        Dim rsaKey As String = System.IO.File.ReadAllText(Server.MapPath("") & "/Key/KMKey.key")


        Dim scopes = New List(Of String) From {
        "signature"
    }
        Dim authToken As OAuth.OAuthToken = apiClient.RequestJWTUserToken(ik, userId, authserver, Encoding.UTF8.GetBytes(rsaKey), 1, scopes)
        Dim accessToken As String = authToken.access_token

Solution

You need to set the baseURL for your production account. It is not the same for all customers, so you have to retrieve it using getUserInformation() command.

You can also find your baseURL on the Apps and Keys page if you go there at the top.



Answered By - Inbar Gazit
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing