Chilkat Online Tools

Foxpro / easybill REST API / Send document

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
LOCAL lnRespStatusCode

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
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.

* {
*   "to": "<string>",
*   "cc": "<string>",
*   "from": "<string>",
*   "subject": "<string>",
*   "message": "<string>",
*   "date": "<date>",
*   "send_by_self": "<boolean>",
*   "send_with_attachment": "true",
*   "document_file_type": "default",
*   "post_send_type": "post_send_type_prio"
* }

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("to","<string>")
loJson.UpdateString("cc","<string>")
loJson.UpdateString("from","<string>")
loJson.UpdateString("subject","<string>")
loJson.UpdateString("message","<string>")
loJson.UpdateString("date","<date>")
loJson.UpdateString("send_by_self","<boolean>")
loJson.UpdateString("send_with_attachment","true")
loJson.UpdateString("document_file_type","default")
loJson.UpdateString("post_send_type","post_send_type_prio")

loHttp.SetRequestHeader("Authorization","{{apiKey}}")
loHttp.SetRequestHeader("Content-Type","application/json")

loResp = loHttp.PostJson3("https://api.easybill.de/rest/v1/documents/:id/send/:type","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 204) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Response Body:"
    ? loResp.BodyStr
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

RELEASE loResp
? "Success."

RELEASE loHttp
RELEASE loJson

Curl Command

curl -X POST
	-H "Authorization: {{apiKey}}"
	-H "Content-Type: application/json"
	-d '{
  "to": "<string>",
  "cc": "<string>",
  "from": "<string>",
  "subject": "<string>",
  "message": "<string>",
  "date": "<date>",
  "send_by_self": "<boolean>",
  "send_with_attachment": "true",
  "document_file_type": "default",
  "post_send_type": "post_send_type_prio"
}'
https://api.easybill.de/rest/v1/documents/:id/send/:type

Postman Collection Item JSON

{
  "name": "Send document",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"to\": \"<string>\",\n  \"cc\": \"<string>\",\n  \"from\": \"<string>\",\n  \"subject\": \"<string>\",\n  \"message\": \"<string>\",\n  \"date\": \"<date>\",\n  \"send_by_self\": \"<boolean>\",\n  \"send_with_attachment\": \"true\",\n  \"document_file_type\": \"default\",\n  \"post_send_type\": \"post_send_type_prio\"\n}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/documents/:id/send/:type",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "documents",
        ":id",
        "send",
        ":type"
      ],
      "variable": [
        {
          "key": "id",
          "value": "<long>",
          "description": "(Required) ID of document"
        },
        {
          "key": "type",
          "value": "fax",
          "description": "(Required) "
        }
      ]
    }
  },
  "response": [
    {
      "name": "Successful operation",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"to\": \"<string>\",\n  \"cc\": \"<string>\",\n  \"from\": \"<string>\",\n  \"subject\": \"<string>\",\n  \"message\": \"<string>\",\n  \"date\": \"<date>\",\n  \"send_by_self\": \"<boolean>\",\n  \"send_with_attachment\": \"true\",\n  \"document_file_type\": \"default\",\n  \"post_send_type\": \"post_send_type_prio\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/documents/:id/send/:type",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            "send",
            ":type"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "type"
            }
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Not found",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"to\": \"<string>\",\n  \"cc\": \"<string>\",\n  \"from\": \"<string>\",\n  \"subject\": \"<string>\",\n  \"message\": \"<string>\",\n  \"date\": \"<date>\",\n  \"send_by_self\": \"<boolean>\",\n  \"send_with_attachment\": \"true\",\n  \"document_file_type\": \"default\",\n  \"post_send_type\": \"post_send_type_prio\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/documents/:id/send/:type",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            "send",
            ":type"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "type"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Too Many Requests",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"to\": \"<string>\",\n  \"cc\": \"<string>\",\n  \"from\": \"<string>\",\n  \"subject\": \"<string>\",\n  \"message\": \"<string>\",\n  \"date\": \"<date>\",\n  \"send_by_self\": \"<boolean>\",\n  \"send_with_attachment\": \"true\",\n  \"document_file_type\": \"default\",\n  \"post_send_type\": \"post_send_type_prio\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/documents/:id/send/:type",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            "send",
            ":type"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "type"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}