We're using the Docusign API to create a new template from a custom document and signer definition. Everything was working before, but then we switched over to the JWT Authentication flow instead of the Authorization Code Grant (so users could impersonate our admin Docusign account without having to sign in), and suddenly this error started popping up whenever we try to create a new template. Specifically, the
templates_api.create_template(account_id=account_id, envelope_template=template_req_object)
function call returns the 404 error. The full code and error message are below:
# Creates an envelope on Docusign and sends a remote signing link for it to a
# destination email.
#
# Returns: the envelope_id of the created envelope
def create_application_envelope(destination_email, base64_file_content, signer_name="PlanProvide", signer_tabs=None, is_embedded_signing=False):
# Create an application envelope
# docusign_auth.DSClient.login("jwt")
account_id = session["ds_account_id"]
envelope_api = docusign_api_handler.get_envelope_api()
templates_api = docusign_api_handler.get_templates_api()
signer = Signer(
email=destination_email,
name=signer_name,
recipient_id="1",
routing_order="1",
role_name="signer",
tabs=signer_tabs
)
# Setting the client_user_id marks the signer as embedded
if is_embedded_signing:
signer.client_user_id = 1000
doc = Document(
document_base64 = base64_file_content,
name = "Your application generated by PlanProvide",
file_extension = "pdf",
document_id = 1,
# Detect Adobe form field names
transform_pdf_fields = True
)
documents = [doc]
template_req_object = EnvelopeTemplate(
documents=documents, email_subject="Please sign this document",
recipients=Recipients(signers=[signer]),
description="Template created via the API",
name="Application Template",
shared="false",
status="created"
)
print("creating template")
print(account_id)
pdb.set_trace()
try:
res = templates_api.create_template(account_id=account_id, envelope_template=template_req_object)
except Exception as e:
raise DocusignError(e)
print("template created")
results = res.templates[0]
template_id = results.template_id
envelope_definition = EnvelopeDefinition(
email_subject="Please sign this document sent from the Python SDK",
template_id=template_id,
template_roles=[signer],
status="sent" # requests that the envelope be created and sent.
)
This results in the following error:
(404) Reason: Not Found HTTP response headers: HTTPHeaderDict({'Content-Type': 'text/html', 'X-DocuSign-Node': 'DA1DFE6', 'Date': 'Tue, 10 Nov 2020 16:41:05 GMT', 'Content-Length': '1245', 'Set-Cookie': 'BIGipDocuSign_Demo=!/XAG+47L0RctJFuU4V8NQL3lsxkc/YD8Zqi4arG0TDtpOLO4xA9ujpq18pIyNxItCax5phqd7d86Zas=; path=/; Httponly; Secure', 'Connection': 'close'}) HTTP response body: b'\r\n\r\n\r\n\r\n404 - File or directory not found.
Really not sure what could be causing this. It seems like we're making a pretty standard POST request to this URL: "https://demo.docusign.net/v2.1/accounts/[accountID]/templates" (found by digging into the Python docusign library for the "create_template" definition). If I paste this URL into my browser, it also results in a 404 error. I've checked that this is my correct API Account ID in the URL.
Is this the correct URL? Or is there any other reason that Docusign would reject this request?