Java / DocuSign Click API / 18. Send Envelope with Template
        
        Back to Collection Items
        import com.chilkatsoft.*;
public class ChilkatExample {
  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }
  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.
    CkHttp http = new CkHttp();
    boolean success;
    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON
    // The following JSON is sent in the request body.
    // {
    //   "emailBlurb": "Create an envelope with a templateId",
    //   "emailSubject": "Template",
    //   "templateId": "{{templateId}}",
    //   "status": "sent"
    // }
    CkJsonObject json = new CkJsonObject();
    json.UpdateString("emailBlurb","Create an envelope with a templateId");
    json.UpdateString("emailSubject","Template");
    json.UpdateString("templateId","{{templateId}}");
    json.UpdateString("status","sent");
    // Adds the "Authorization: Bearer {{accessToken}}" header.
    http.put_AuthToken("{{accessToken}}");
    CkHttpResponse resp = new CkHttpResponse();
    success = http.HttpJson("POST","https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes",json,"application/json",resp);
    if (success == false) {
        System.out.println(http.lastErrorText());
        return;
        }
    System.out.println(resp.get_StatusCode());
    System.out.println(resp.bodyStr());
  }
}
        Curl Command
        curl -X POST
	-H "Authorization: Bearer {{accessToken}}"
	-d '{
    "emailBlurb": "Create an envelope with a templateId",
    "emailSubject": "Template",
    "templateId": "{{templateId}}",
    "status": "sent"
}'
https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes
        Postman Collection Item JSON
        {
  "name": "18. Send Envelope with Template",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"emailBlurb\": \"Create an envelope with a templateId\",\n    \"emailSubject\": \"Template\",\n    \"templateId\": \"{{templateId}}\",\n    \"status\": \"sent\"\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/{{apiVersion}}/accounts/{{accountId}}/envelopes",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "{{apiVersion}}",
        "accounts",
        "{{accountId}}",
        "envelopes"
      ]
    },
    "description": "Send an envelop with a single template."
  },
  "response": [
  ]
}