PowerBuilder / easybill REST API / Fetch PDF Templates list
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
string ls_Name
string ls_Pdf_template
string ls_Document_type
string ls_Text_prefix
string ls_Text
string ls_Subject
string ls_Message
integer i
integer li_Count_i
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")
loo_QueryParams.UpdateString("type","DUNNING,CREDIT")
loo_Http.SetRequestHeader("Authorization","{{apiKey}}")
loo_Http.SetRequestHeader("Accept","application/json")
loo_Resp = loo_Http.QuickRequestParams("GET","https://api.easybill.de/rest/v1/pdf-templates",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_QueryParams
return
end if
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Resp
destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
destroy loo_Resp
// 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
li_Count_i = loo_JResp.SizeOfArray("items")
do while i < li_Count_i
loo_JResp.I = i
ls_Id = loo_JResp.StringOf("items[i].id")
ls_Name = loo_JResp.StringOf("items[i].name")
ls_Pdf_template = loo_JResp.StringOf("items[i].pdf_template")
ls_Document_type = loo_JResp.StringOf("items[i].document_type")
ls_Text_prefix = loo_JResp.StringOf("items[i].settings.text_prefix")
ls_Text = loo_JResp.StringOf("items[i].settings.text")
ls_Subject = loo_JResp.StringOf("items[i].settings.email.subject")
ls_Message = loo_JResp.StringOf("items[i].settings.email.message")
i = i + 1
loop
destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp
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": ""
}
]
}