lianja / easybill REST API / Fetch PDF Templates list
Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
loQueryParams = createobject("CkJsonObject")
loQueryParams.UpdateString("type","DUNNING,CREDIT")
loHttp.SetRequestHeader("Authorization","{{apiKey}}")
loHttp.SetRequestHeader("Accept","application/json")
loResp = loHttp.QuickRequestParams("GET","https://api.easybill.de/rest/v1/pdf-templates",loQueryParams)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loQueryParams
return
endif
loSbResponseBody = createobject("CkStringBuilder")
loResp.GetBodySb(loSbResponseBody)
loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
? "Response Header:"
? loResp.Header
? "Failed."
release loResp
release loHttp
release loQueryParams
release loSbResponseBody
release loJResp
return
endif
release loResp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "items": [
// {
// "id": "INVOICE-DE",
// "name": "Default template",
// "pdf_template": "DE",
// "document_type": "INVOICE",
// "settings": {
// "text_prefix": "",
// "text": "",
// "email": {
// "subject": "",
// "message": ""
// }
// }
// },
// {
// "id": "INVOICE-DE",
// "name": "Default template",
// "pdf_template": "DE",
// "document_type": "INVOICE",
// "settings": {
// "text_prefix": "",
// "text": "",
// "email": {
// "subject": "",
// "message": ""
// }
// }
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
i = 0
lnCount_i = loJResp.SizeOfArray("items")
do while i < lnCount_i
loJResp.I = i
lcId = loJResp.StringOf("items[i].id")
lcName = loJResp.StringOf("items[i].name")
lcPdf_template = loJResp.StringOf("items[i].pdf_template")
lcDocument_type = loJResp.StringOf("items[i].document_type")
lcText_prefix = loJResp.StringOf("items[i].settings.text_prefix")
lcText = loJResp.StringOf("items[i].settings.text")
lcSubject = loJResp.StringOf("items[i].settings.email.subject")
lcMessage = loJResp.StringOf("items[i].settings.email.message")
i = i + 1
enddo
release loHttp
release loQueryParams
release loSbResponseBody
release loJResp
Curl Command
curl -G -d "type=DUNNING,CREDIT"
-H "Authorization: {{apiKey}}"
-H "Accept: application/json"
https://api.easybill.de/rest/v1/pdf-templates
Postman Collection Item JSON
{
"name": "Fetch PDF Templates list",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/pdf-templates?type=DUNNING,CREDIT",
"host": [
"{{baseUrl}}"
],
"path": [
"pdf-templates"
],
"query": [
{
"key": "type",
"value": "DUNNING,CREDIT",
"description": "Filters the templates by the specified type. You can specify several types comma-separated, like type,type,type."
}
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/pdf-templates?type=DUNNING,CREDIT",
"host": [
"{{baseUrl}}"
],
"path": [
"pdf-templates"
],
"query": [
{
"key": "type",
"value": "DUNNING,CREDIT",
"description": "Filters the templates by the specified type. You can specify several types comma-separated, like type,type,type."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"items\": [\n {\n \"id\": \"INVOICE-DE\",\n \"name\": \"Default template\",\n \"pdf_template\": \"DE\",\n \"document_type\": \"INVOICE\",\n \"settings\": {\n \"text_prefix\": \"\",\n \"text\": \"\",\n \"email\": {\n \"subject\": \"\",\n \"message\": \"\"\n }\n }\n },\n {\n \"id\": \"INVOICE-DE\",\n \"name\": \"Default template\",\n \"pdf_template\": \"DE\",\n \"document_type\": \"INVOICE\",\n \"settings\": {\n \"text_prefix\": \"\",\n \"text\": \"\",\n \"email\": {\n \"subject\": \"\",\n \"message\": \"\"\n }\n }\n }\n ]\n}"
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/pdf-templates?type=DUNNING,CREDIT",
"host": [
"{{baseUrl}}"
],
"path": [
"pdf-templates"
],
"query": [
{
"key": "type",
"value": "DUNNING,CREDIT",
"description": "Filters the templates by the specified type. You can specify several types comma-separated, like type,type,type."
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}