Foxpro / DocuSign Click API / 18. Send Envelope with Template
        
        Back to Collection Items
        LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loHttp = CreateObject('Chilkat.Http')
* 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"
* }
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("emailBlurb","Create an envelope with a templateId")
loJson.UpdateString("emailSubject","Template")
loJson.UpdateString("templateId","{{templateId}}")
loJson.UpdateString("status","sent")
* Adds the "Authorization: Bearer {{accessToken}}" header.
loHttp.AuthToken = "{{accessToken}}"
loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpJson("POST","https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes",loJson,"application/json",loResp)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    RELEASE loResp
    CANCEL
ENDIF
? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loHttp
RELEASE loJson
RELEASE loResp
        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": [
  ]
}