Chilkat Online Tools

autoit / easybill REST API / Convert an existing document to one of a different type

Back to Collection Items

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

$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess

$oHttp.SetRequestHeader "Authorization","{{apiKey}}"
$oHttp.SetRequestHeader "Accept","application/json"

Local $oResp = $oHttp.QuickRequest("POST","https://api.easybill.de/rest/v1/documents/:id/:type?pdf_template=DE")
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)

$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oResp.Header & @CRLF)
    ConsoleWrite("Failed." & @CRLF)

    Exit
EndIf

; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)

; {
;   "address": {
;     "salutation": "<integer>",
;     "personal": "<boolean>",
;     "title": "<string>",
;     "first_name": "<string>",
;     "last_name": "<string>",
;     "suffix_1": "<string>",
;     "suffix_2": "<string>",
;     "company_name": "<string>",
;     "street": "<string>",
;     "zip_code": "<string>",
;     "city": "<string>",
;     "state": "<string>",
;     "country": "<string>"
;   },
;   "attachment_ids": [
;     "<integer>",
;     "<integer>"
;   ],
;   "label_address": {
;     "salutation": "<integer>",
;     "personal": "<boolean>",
;     "title": "<string>",
;     "first_name": "<string>",
;     "last_name": "<string>",
;     "suffix_1": "<string>",
;     "suffix_2": "<string>",
;     "company_name": "<string>",
;     "street": "<string>",
;     "zip_code": "<string>",
;     "city": "<string>",
;     "state": "<string>",
;     "country": "<string>"
;   },
;   "amount": "<integer>",
;   "amount_net": "<integer>",
;   "bank_debit_form": null,
;   "billing_country": "<string>",
;   "calc_vat_from": 0,
;   "cancel_id": "<long>",
;   "cash_allowance": null,
;   "cash_allowance_days": null,
;   "cash_allowance_text": null,
;   "contact_id": null,
;   "contact_label": "",
;   "contact_text": "",
;   "created_at": "<dateTime>",
;   "currency": "EUR",
;   "customer_id": null,
;   "customer_snapshot": {
;     "last_name": "<string>",
;     "company_name": "<string>",
;     "acquire_options": 2,
;     "additional_groups_ids": [
;       "<integer>",
;       "<integer>"
;     ],
;     "bank_account": "<string>",
;     "bank_account_owner": "<string>",
;     "bank_bic": "<string>",
;     "bank_code": "<string>",
;     "bank_iban": "<string>",
;     "bank_name": "<string>",
;     "birth_date": "<date>",
;     "cash_allowance": "<float>",
;     "cash_allowance_days": 7,
;     "cash_discount": "<float>",
;     "cash_discount_type": "AMOUNT",
;     "city": "<string>",
;     "state": "<string>",
;     "country": "<string>",
;     "created_at": "<date>",
;     "updated_at": "<string>",
;     "delivery_title": "<string>",
;     "delivery_city": "<string>",
;     "delivery_state": "<string>",
;     "delivery_company_name": "<string>",
;     "delivery_country": "<string>",
;     "delivery_first_name": "<string>",
;     "delivery_last_name": "<string>",
;     "delivery_personal": "<boolean>",
;     "delivery_salutation": 0,
;     "delivery_street": "<string>",
;     "delivery_suffix_1": "<string>",
;     "delivery_suffix_2": "<string>",
;     "delivery_zip_code": "<string>",
;     "display_name": "<string>",
;     "emails": [
;       "<string>",
;       "<string>"
;     ],
;     "fax": "<string>",
;     "first_name": "<string>",
;     "grace_period": "<integer>",
;     "due_in_days": "<integer>",
;     "group_id": "<integer>",
;     "id": "<long>",
;     "info_1": "<string>",
;     "info_2": "<string>",
;     "internet": "<string>",
;     "login_id": "<long>",
;     "mobile": "<string>",
;     "note": "<string>",
;     "number": "<string>",
;     "payment_options": 1,
;     "personal": false,
;     "phone_1": "<string>",
;     "phone_2": "<string>",
;     "postbox": "<string>",
;     "postbox_city": "<string>",
;     "postbox_state": "<string>",
;     "postbox_country": "<string>",
;     "postbox_zip_code": "<string>",
;     "sale_price_level": "SALEPRICE6",
;     "salutation": 0,
;     "sepa_agreement": "BASIC",
;     "sepa_agreement_date": "<date>",
;     "sepa_mandate_reference": "<string>",
;     "since_date": "<date>",
;     "street": "<string>",
;     "suffix_1": "<string>",
;     "suffix_2": "<string>",
;     "tax_number": "<string>",
;     "court": "<string>",
;     "court_registry_number": "<string>",
;     "tax_options": "nStbIm",
;     "title": "<string>",
;     "archived": "<boolean>",
;     "vat_identifier": "<string>",
;     "zip_code": "<string>",
;     "document_pdf_type": "default",
;     "buyer_reference": "<string>",
;     "foreign_supplier_number": "<string>"
;   },
;   "discount": null,
;   "discount_type": null,
;   "document_date": "<date>",
;   "due_date": "<date>",
;   "edited_at": "<dateTime>",
;   "external_id": null,
;   "replica_url": null,
;   "grace_period": "<integer>",
;   "due_in_days": "<integer>",
;   "id": "<long>",
;   "is_acceptable_on_public_domain": false,
;   "is_archive": false,
;   "is_draft": "<boolean>",
;   "is_replica": false,
;   "is_oss": false,
;   "item_notes": [
;     "<string>",
;     "<string>"
;   ],
;   "items": [
;     {
;       "number": null,
;       "description": null,
;       "document_note": "<string>",
;       "quantity": 1,
;       "quantity_str": "<string>",
;       "unit": null,
;       "type": "POSITION",
;       "position": "<integer>",
;       "single_price_net": null,
;       "single_price_gross": "<float>",
;       "vat_percent": 0,
;       "discount": null,
;       "discount_type": null,
;       "position_id": null,
;       "total_price_net": "<float>",
;       "total_price_gross": "<float>",
;       "total_vat": "<float>",
;       "serial_number_id": "<string>",
;       "serial_number": "<string>",
;       "booking_account": null,
;       "export_cost_1": null,
;       "export_cost_2": null,
;       "cost_price_net": null,
;       "cost_price_total": "<float>",
;       "cost_price_charge": "<float>",
;       "cost_price_charge_type": "PERCENT",
;       "itemType": "UNDEFINED",
;       "id": "<long>"
;     },
;     {
;       "number": null,
;       "description": null,
;       "document_note": "<string>",
;       "quantity": 1,
;       "quantity_str": "<string>",
;       "unit": null,
;       "type": "POSITION",
;       "position": "<integer>",
;       "single_price_net": null,
;       "single_price_gross": "<float>",
;       "vat_percent": 0,
;       "discount": null,
;       "discount_type": null,
;       "position_id": null,
;       "total_price_net": "<float>",
;       "total_price_gross": "<float>",
;       "total_vat": "<float>",
;       "serial_number_id": "<string>",
;       "serial_number": "<string>",
;       "booking_account": null,
;       "export_cost_1": null,
;       "export_cost_2": null,
;       "cost_price_net": null,
;       "cost_price_total": "<float>",
;       "cost_price_charge": "<float>",
;       "cost_price_charge_type": "PERCENT",
;       "itemType": "UNDEFINED",
;       "id": "<long>"
;     }
;   ],
;   "last_postbox_id": "<long>",
;   "login_id": "<long>",
;   "number": null,
;   "order_number": "",
;   "buyer_reference": "",
;   "paid_amount": "<integer>",
;   "paid_at": "<date>",
;   "pdf_pages": "<integer>",
;   "pdf_template": "<string>",
;   "project_id": null,
;   "recurring_options": {
;     "next_date": "<date>",
;     "frequency": "MONTHLY",
;     "frequency_special": null,
;     "interval": 1,
;     "end_date_or_count": null,
;     "status": "WAITING",
;     "as_draft": false,
;     "is_notify": false,
;     "send_as": null,
;     "is_sign": false,
;     "is_paid": false,
;     "paid_date_option": "created_date",
;     "is_sepa": false,
;     "sepa_local_instrument": null,
;     "sepa_sequence_type": null,
;     "sepa_reference": null,
;     "sepa_remittance_information": null,
;     "target_type": "INVOICE"
;   },
;   "ref_id": null,
;   "root_id": null,
;   "service_date": {
;     "type": "SERVICE",
;     "date": "<date>",
;     "date_from": "<date>",
;     "date_to": "<date>",
;     "text": null
;   },
;   "shipping_country": null,
;   "status": null,
;   "text": "<string>",
;   "text_prefix": "<string>",
;   "text_tax": null,
;   "title": null,
;   "type": "INVOICE",
;   "use_shipping_address": false,
;   "vat_country": null,
;   "vat_id": "",
;   "fulfillment_country": null,
;   "vat_option": null,
;   "file_format_config": [
;     {
;       "type": "xrechnung2_2_xml"
;     },
;     {
;       "type": "xrechnung3_0_xml"
;     }
;   ]
; }

; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

$oDate_from = ObjCreate("Chilkat.DtObj")
$oDate_to = ObjCreate("Chilkat.DtObj")
Local $strVal
Local $sDescription
Local $sDocument_note
Local $iQuantity
Local $sQuantity_str
Local $sUnit
Local $sPosition
Local $single_price_net
Local $single_price_gross
Local $iVat_percent
Local $sPosition_id
Local $sTotal_price_net
Local $sTotal_price_gross
Local $sTotal_vat
Local $serial_number_id
Local $serial_number
Local $sBooking_account
Local $sExport_cost_1
Local $sExport_cost_2
Local $sCost_price_net
Local $sCost_price_total
Local $sCost_price_charge
Local $sCost_price_charge_type
Local $sItemType

Local $sSalutation = $oJResp.StringOf("address.salutation")
Local $sPersonal = $oJResp.StringOf("address.personal")
Local $sTitle = $oJResp.StringOf("address.title")
Local $sFirst_name = $oJResp.StringOf("address.first_name")
Local $sLast_name = $oJResp.StringOf("address.last_name")
Local $sSuffix_1 = $oJResp.StringOf("address.suffix_1")
Local $sSuffix_2 = $oJResp.StringOf("address.suffix_2")
Local $sCompany_name = $oJResp.StringOf("address.company_name")
Local $sStreet = $oJResp.StringOf("address.street")
Local $sZip_code = $oJResp.StringOf("address.zip_code")
Local $sCity = $oJResp.StringOf("address.city")
Local $sState = $oJResp.StringOf("address.state")
Local $sCountry = $oJResp.StringOf("address.country")
Local $sLabel_addressSalutation = $oJResp.StringOf("label_address.salutation")
Local $sLabel_addressPersonal = $oJResp.StringOf("label_address.personal")
Local $sLabel_addressTitle = $oJResp.StringOf("label_address.title")
Local $sLabel_addressFirst_name = $oJResp.StringOf("label_address.first_name")
Local $sLabel_addressLast_name = $oJResp.StringOf("label_address.last_name")
Local $sLabel_addressSuffix_1 = $oJResp.StringOf("label_address.suffix_1")
Local $sLabel_addressSuffix_2 = $oJResp.StringOf("label_address.suffix_2")
Local $sLabel_addressCompany_name = $oJResp.StringOf("label_address.company_name")
Local $sLabel_addressStreet = $oJResp.StringOf("label_address.street")
Local $sLabel_addressZip_code = $oJResp.StringOf("label_address.zip_code")
Local $sLabel_addressCity = $oJResp.StringOf("label_address.city")
Local $sLabel_addressState = $oJResp.StringOf("label_address.state")
Local $sLabel_addressCountry = $oJResp.StringOf("label_address.country")
Local $sAmount = $oJResp.StringOf("amount")
Local $sAmount_net = $oJResp.StringOf("amount_net")
Local $sBank_debit_form = $oJResp.StringOf("bank_debit_form")
Local $sBilling_country = $oJResp.StringOf("billing_country")
Local $iCalc_vat_from = $oJResp.IntOf("calc_vat_from")
Local $sCancel_id = $oJResp.StringOf("cancel_id")
Local $sCash_allowance = $oJResp.StringOf("cash_allowance")
Local $sCash_allowance_days = $oJResp.StringOf("cash_allowance_days")
Local $sCash_allowance_text = $oJResp.StringOf("cash_allowance_text")
Local $sContact_id = $oJResp.StringOf("contact_id")
Local $sContact_label = $oJResp.StringOf("contact_label")
Local $sContact_text = $oJResp.StringOf("contact_text")
Local $sCreated_at = $oJResp.StringOf("created_at")
Local $sV_currency = $oJResp.StringOf("currency")
Local $sCustomer_id = $oJResp.StringOf("customer_id")
Local $sCustomer_snapshotLast_name = $oJResp.StringOf("customer_snapshot.last_name")
Local $sCustomer_snapshotCompany_name = $oJResp.StringOf("customer_snapshot.company_name")
Local $iAcquire_options = $oJResp.IntOf("customer_snapshot.acquire_options")
Local $sBank_account = $oJResp.StringOf("customer_snapshot.bank_account")
Local $sBank_account_owner = $oJResp.StringOf("customer_snapshot.bank_account_owner")
Local $sBank_bic = $oJResp.StringOf("customer_snapshot.bank_bic")
Local $sBank_code = $oJResp.StringOf("customer_snapshot.bank_code")
Local $sBank_iban = $oJResp.StringOf("customer_snapshot.bank_iban")
Local $sBank_name = $oJResp.StringOf("customer_snapshot.bank_name")
Local $sBirth_date = $oJResp.StringOf("customer_snapshot.birth_date")
Local $sCash_allowance = $oJResp.StringOf("customer_snapshot.cash_allowance")
Local $iCash_allowance_days = $oJResp.IntOf("customer_snapshot.cash_allowance_days")
Local $sCash_discount = $oJResp.StringOf("customer_snapshot.cash_discount")
Local $sCash_discount_type = $oJResp.StringOf("customer_snapshot.cash_discount_type")
Local $sCustomer_snapshotCity = $oJResp.StringOf("customer_snapshot.city")
Local $sCustomer_snapshotState = $oJResp.StringOf("customer_snapshot.state")
Local $sCustomer_snapshotCountry = $oJResp.StringOf("customer_snapshot.country")
Local $sCreated_at = $oJResp.StringOf("customer_snapshot.created_at")
Local $sUpdated_at = $oJResp.StringOf("customer_snapshot.updated_at")
Local $sDelivery_title = $oJResp.StringOf("customer_snapshot.delivery_title")
Local $sDelivery_city = $oJResp.StringOf("customer_snapshot.delivery_city")
Local $sDelivery_state = $oJResp.StringOf("customer_snapshot.delivery_state")
Local $sDelivery_company_name = $oJResp.StringOf("customer_snapshot.delivery_company_name")
Local $sDelivery_country = $oJResp.StringOf("customer_snapshot.delivery_country")
Local $sDelivery_first_name = $oJResp.StringOf("customer_snapshot.delivery_first_name")
Local $sDelivery_last_name = $oJResp.StringOf("customer_snapshot.delivery_last_name")
Local $sDelivery_personal = $oJResp.StringOf("customer_snapshot.delivery_personal")
Local $iDelivery_salutation = $oJResp.IntOf("customer_snapshot.delivery_salutation")
Local $sDelivery_street = $oJResp.StringOf("customer_snapshot.delivery_street")
Local $sDelivery_suffix_1 = $oJResp.StringOf("customer_snapshot.delivery_suffix_1")
Local $sDelivery_suffix_2 = $oJResp.StringOf("customer_snapshot.delivery_suffix_2")
Local $sDelivery_zip_code = $oJResp.StringOf("customer_snapshot.delivery_zip_code")
Local $sDisplay_name = $oJResp.StringOf("customer_snapshot.display_name")
Local $sFax = $oJResp.StringOf("customer_snapshot.fax")
Local $sCustomer_snapshotFirst_name = $oJResp.StringOf("customer_snapshot.first_name")
Local $sGrace_period = $oJResp.StringOf("customer_snapshot.grace_period")
Local $sDue_in_days = $oJResp.StringOf("customer_snapshot.due_in_days")
Local $sGroup_id = $oJResp.StringOf("customer_snapshot.group_id")
Local $sId = $oJResp.StringOf("customer_snapshot.id")
Local $sInfo_1 = $oJResp.StringOf("customer_snapshot.info_1")
Local $sInfo_2 = $oJResp.StringOf("customer_snapshot.info_2")
Local $sInternet = $oJResp.StringOf("customer_snapshot.internet")
Local $sLogin_id = $oJResp.StringOf("customer_snapshot.login_id")
Local $sMobile = $oJResp.StringOf("customer_snapshot.mobile")
Local $sNote = $oJResp.StringOf("customer_snapshot.note")
Local $sV_Number = $oJResp.StringOf("customer_snapshot.number")
Local $iPayment_options = $oJResp.IntOf("customer_snapshot.payment_options")
Local $bCustomer_snapshotPersonal = $oJResp.BoolOf("customer_snapshot.personal")
Local $sPhone_1 = $oJResp.StringOf("customer_snapshot.phone_1")
Local $sPhone_2 = $oJResp.StringOf("customer_snapshot.phone_2")
Local $sPostbox = $oJResp.StringOf("customer_snapshot.postbox")
Local $sPostbox_city = $oJResp.StringOf("customer_snapshot.postbox_city")
Local $sPostbox_state = $oJResp.StringOf("customer_snapshot.postbox_state")
Local $sPostbox_country = $oJResp.StringOf("customer_snapshot.postbox_country")
Local $sPostbox_zip_code = $oJResp.StringOf("customer_snapshot.postbox_zip_code")
Local $sSale_price_level = $oJResp.StringOf("customer_snapshot.sale_price_level")
Local $iCustomer_snapshotSalutation = $oJResp.IntOf("customer_snapshot.salutation")
Local $sSepa_agreement = $oJResp.StringOf("customer_snapshot.sepa_agreement")
Local $sSepa_agreement_date = $oJResp.StringOf("customer_snapshot.sepa_agreement_date")
Local $sSepa_mandate_reference = $oJResp.StringOf("customer_snapshot.sepa_mandate_reference")
Local $sSince_date = $oJResp.StringOf("customer_snapshot.since_date")
Local $sCustomer_snapshotStreet = $oJResp.StringOf("customer_snapshot.street")
Local $sCustomer_snapshotSuffix_1 = $oJResp.StringOf("customer_snapshot.suffix_1")
Local $sCustomer_snapshotSuffix_2 = $oJResp.StringOf("customer_snapshot.suffix_2")
Local $sTax_number = $oJResp.StringOf("customer_snapshot.tax_number")
Local $sCourt = $oJResp.StringOf("customer_snapshot.court")
Local $sCourt_registry_number = $oJResp.StringOf("customer_snapshot.court_registry_number")
Local $sTax_options = $oJResp.StringOf("customer_snapshot.tax_options")
Local $sCustomer_snapshotTitle = $oJResp.StringOf("customer_snapshot.title")
Local $sArchived = $oJResp.StringOf("customer_snapshot.archived")
Local $sVat_identifier = $oJResp.StringOf("customer_snapshot.vat_identifier")
Local $sCustomer_snapshotZip_code = $oJResp.StringOf("customer_snapshot.zip_code")
Local $sDocument_pdf_type = $oJResp.StringOf("customer_snapshot.document_pdf_type")
Local $sBuyer_reference = $oJResp.StringOf("customer_snapshot.buyer_reference")
Local $sForeign_supplier_number = $oJResp.StringOf("customer_snapshot.foreign_supplier_number")
Local $sDiscount = $oJResp.StringOf("discount")
Local $sDiscount_type = $oJResp.StringOf("discount_type")
Local $sDocument_date = $oJResp.StringOf("document_date")
Local $sDue_date = $oJResp.StringOf("due_date")
Local $sEdited_at = $oJResp.StringOf("edited_at")
Local $sExternal_id = $oJResp.StringOf("external_id")
Local $sReplica_url = $oJResp.StringOf("replica_url")
Local $sGrace_period = $oJResp.StringOf("grace_period")
Local $sDue_in_days = $oJResp.StringOf("due_in_days")
Local $sId = $oJResp.StringOf("id")
Local $bIs_acceptable_on_public_domain = $oJResp.BoolOf("is_acceptable_on_public_domain")
Local $bIs_archive = $oJResp.BoolOf("is_archive")
Local $sIs_draft = $oJResp.StringOf("is_draft")
Local $bIs_replica = $oJResp.BoolOf("is_replica")
Local $bIs_oss = $oJResp.BoolOf("is_oss")
Local $sLast_postbox_id = $oJResp.StringOf("last_postbox_id")
Local $sLogin_id = $oJResp.StringOf("login_id")
Local $sV_number = $oJResp.StringOf("number")
Local $sOrder_number = $oJResp.StringOf("order_number")
Local $sBuyer_reference = $oJResp.StringOf("buyer_reference")
Local $sPaid_amount = $oJResp.StringOf("paid_amount")
Local $sPaid_at = $oJResp.StringOf("paid_at")
Local $sPdf_pages = $oJResp.StringOf("pdf_pages")
Local $sPdf_template = $oJResp.StringOf("pdf_template")
Local $sProject_id = $oJResp.StringOf("project_id")
Local $sNext_date = $oJResp.StringOf("recurring_options.next_date")
Local $sFrequency = $oJResp.StringOf("recurring_options.frequency")
Local $sFrequency_special = $oJResp.StringOf("recurring_options.frequency_special")
Local $iInterval = $oJResp.IntOf("recurring_options.interval")
Local $sEnd_date_or_count = $oJResp.StringOf("recurring_options.end_date_or_count")
Local $sStatus = $oJResp.StringOf("recurring_options.status")
Local $bAs_draft = $oJResp.BoolOf("recurring_options.as_draft")
Local $bIs_notify = $oJResp.BoolOf("recurring_options.is_notify")
Local $sSend_as = $oJResp.StringOf("recurring_options.send_as")
Local $bIs_sign = $oJResp.BoolOf("recurring_options.is_sign")
Local $bIs_paid = $oJResp.BoolOf("recurring_options.is_paid")
Local $sPaid_date_option = $oJResp.StringOf("recurring_options.paid_date_option")
Local $bIs_sepa = $oJResp.BoolOf("recurring_options.is_sepa")
Local $sSepa_local_instrument = $oJResp.StringOf("recurring_options.sepa_local_instrument")
Local $sSepa_sequence_type = $oJResp.StringOf("recurring_options.sepa_sequence_type")
Local $sSepa_reference = $oJResp.StringOf("recurring_options.sepa_reference")
Local $sSepa_remittance_information = $oJResp.StringOf("recurring_options.sepa_remittance_information")
Local $sTarget_type = $oJResp.StringOf("recurring_options.target_type")
Local $sRef_id = $oJResp.StringOf("ref_id")
Local $sRoot_id = $oJResp.StringOf("root_id")
Local $sV_Type = $oJResp.StringOf("service_date.type")
Local $sDate = $oJResp.StringOf("service_date.date")
$oJResp.DtOf("service_date.date_from",False,$oDate_from)
$oJResp.DtOf("service_date.date_to",False,$oDate_to)
Local $sText = $oJResp.StringOf("service_date.text")
Local $shipping_country = $oJResp.StringOf("shipping_country")
Local $status = $oJResp.StringOf("status")
Local $sText = $oJResp.StringOf("text")
Local $sText_prefix = $oJResp.StringOf("text_prefix")
Local $sText_tax = $oJResp.StringOf("text_tax")
Local $sTitle = $oJResp.StringOf("title")
Local $sV_type = $oJResp.StringOf("type")
Local $bUse_shipping_address = $oJResp.BoolOf("use_shipping_address")
Local $sVat_country = $oJResp.StringOf("vat_country")
Local $sVat_id = $oJResp.StringOf("vat_id")
Local $sFulfillment_country = $oJResp.StringOf("fulfillment_country")
Local $sVat_option = $oJResp.StringOf("vat_option")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("attachment_ids")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("attachment_ids[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("customer_snapshot.additional_groups_ids")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("customer_snapshot.additional_groups_ids[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("customer_snapshot.emails")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("customer_snapshot.emails[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("item_notes")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("item_notes[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("items")
While $i < $iCount_i
    $oJResp.I = $i
    $sV_number = $oJResp.StringOf("items[i].number")
    $sDescription = $oJResp.StringOf("items[i].description")
    $sDocument_note = $oJResp.StringOf("items[i].document_note")
    $iQuantity = $oJResp.IntOf("items[i].quantity")
    $sQuantity_str = $oJResp.StringOf("items[i].quantity_str")
    $sUnit = $oJResp.StringOf("items[i].unit")
    $sV_type = $oJResp.StringOf("items[i].type")
    $sPosition = $oJResp.StringOf("items[i].position")
    $single_price_net = $oJResp.StringOf("items[i].single_price_net")
    $single_price_gross = $oJResp.StringOf("items[i].single_price_gross")
    $iVat_percent = $oJResp.IntOf("items[i].vat_percent")
    $sDiscount = $oJResp.StringOf("items[i].discount")
    $sDiscount_type = $oJResp.StringOf("items[i].discount_type")
    $sPosition_id = $oJResp.StringOf("items[i].position_id")
    $sTotal_price_net = $oJResp.StringOf("items[i].total_price_net")
    $sTotal_price_gross = $oJResp.StringOf("items[i].total_price_gross")
    $sTotal_vat = $oJResp.StringOf("items[i].total_vat")
    $serial_number_id = $oJResp.StringOf("items[i].serial_number_id")
    $serial_number = $oJResp.StringOf("items[i].serial_number")
    $sBooking_account = $oJResp.StringOf("items[i].booking_account")
    $sExport_cost_1 = $oJResp.StringOf("items[i].export_cost_1")
    $sExport_cost_2 = $oJResp.StringOf("items[i].export_cost_2")
    $sCost_price_net = $oJResp.StringOf("items[i].cost_price_net")
    $sCost_price_total = $oJResp.StringOf("items[i].cost_price_total")
    $sCost_price_charge = $oJResp.StringOf("items[i].cost_price_charge")
    $sCost_price_charge_type = $oJResp.StringOf("items[i].cost_price_charge_type")
    $sItemType = $oJResp.StringOf("items[i].itemType")
    $sId = $oJResp.StringOf("items[i].id")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("file_format_config")
While $i < $iCount_i
    $oJResp.I = $i
    $sV_type = $oJResp.StringOf("file_format_config[i].type")
    $i = $i + 1
Wend

Curl Command

curl -X POST
	-H "Authorization: {{apiKey}}"
	-H "Accept: application/json"
https://api.easybill.de/rest/v1/documents/:id/:type?pdf_template=DE

Postman Collection Item JSON

{
  "name": "Convert an existing document to one of a different type",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/documents/:id/:type?pdf_template=DE",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "documents",
        ":id",
        ":type"
      ],
      "query": [
        {
          "key": "pdf_template",
          "value": "DE",
          "description": "The ID of the printer template to use. Defaults to 'DE' if not given."
        }
      ],
      "variable": [
        {
          "key": "id",
          "value": "<long>",
          "description": "(Required) ID of document"
        },
        {
          "key": "type",
          "value": "DUNNING",
          "description": "(Required) The target document type"
        }
      ]
    }
  },
  "response": [
    {
      "name": "Successful operation",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/documents/:id/:type?pdf_template=DE",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            ":type"
          ],
          "query": [
            {
              "key": "pdf_template",
              "value": "DE",
              "description": "The ID of the printer template to use. Defaults to 'DE' if not given."
            }
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "type"
            }
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        },
        {
          "key": "Location",
          "value": "<uri>",
          "description": {
            "content": "Absolute URL to the newly created document",
            "type": "text/plain"
          }
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"address\": {\n    \"salutation\": \"<integer>\",\n    \"personal\": \"<boolean>\",\n    \"title\": \"<string>\",\n    \"first_name\": \"<string>\",\n    \"last_name\": \"<string>\",\n    \"suffix_1\": \"<string>\",\n    \"suffix_2\": \"<string>\",\n    \"company_name\": \"<string>\",\n    \"street\": \"<string>\",\n    \"zip_code\": \"<string>\",\n    \"city\": \"<string>\",\n    \"state\": \"<string>\",\n    \"country\": \"<string>\"\n  },\n  \"attachment_ids\": [\n    \"<integer>\",\n    \"<integer>\"\n  ],\n  \"label_address\": {\n    \"salutation\": \"<integer>\",\n    \"personal\": \"<boolean>\",\n    \"title\": \"<string>\",\n    \"first_name\": \"<string>\",\n    \"last_name\": \"<string>\",\n    \"suffix_1\": \"<string>\",\n    \"suffix_2\": \"<string>\",\n    \"company_name\": \"<string>\",\n    \"street\": \"<string>\",\n    \"zip_code\": \"<string>\",\n    \"city\": \"<string>\",\n    \"state\": \"<string>\",\n    \"country\": \"<string>\"\n  },\n  \"amount\": \"<integer>\",\n  \"amount_net\": \"<integer>\",\n  \"bank_debit_form\": null,\n  \"billing_country\": \"<string>\",\n  \"calc_vat_from\": 0,\n  \"cancel_id\": \"<long>\",\n  \"cash_allowance\": null,\n  \"cash_allowance_days\": null,\n  \"cash_allowance_text\": null,\n  \"contact_id\": null,\n  \"contact_label\": \"\",\n  \"contact_text\": \"\",\n  \"created_at\": \"<dateTime>\",\n  \"currency\": \"EUR\",\n  \"customer_id\": null,\n  \"customer_snapshot\": {\n    \"last_name\": \"<string>\",\n    \"company_name\": \"<string>\",\n    \"acquire_options\": 2,\n    \"additional_groups_ids\": [\n      \"<integer>\",\n      \"<integer>\"\n    ],\n    \"bank_account\": \"<string>\",\n    \"bank_account_owner\": \"<string>\",\n    \"bank_bic\": \"<string>\",\n    \"bank_code\": \"<string>\",\n    \"bank_iban\": \"<string>\",\n    \"bank_name\": \"<string>\",\n    \"birth_date\": \"<date>\",\n    \"cash_allowance\": \"<float>\",\n    \"cash_allowance_days\": 7,\n    \"cash_discount\": \"<float>\",\n    \"cash_discount_type\": \"AMOUNT\",\n    \"city\": \"<string>\",\n    \"state\": \"<string>\",\n    \"country\": \"<string>\",\n    \"created_at\": \"<date>\",\n    \"updated_at\": \"<string>\",\n    \"delivery_title\": \"<string>\",\n    \"delivery_city\": \"<string>\",\n    \"delivery_state\": \"<string>\",\n    \"delivery_company_name\": \"<string>\",\n    \"delivery_country\": \"<string>\",\n    \"delivery_first_name\": \"<string>\",\n    \"delivery_last_name\": \"<string>\",\n    \"delivery_personal\": \"<boolean>\",\n    \"delivery_salutation\": 0,\n    \"delivery_street\": \"<string>\",\n    \"delivery_suffix_1\": \"<string>\",\n    \"delivery_suffix_2\": \"<string>\",\n    \"delivery_zip_code\": \"<string>\",\n    \"display_name\": \"<string>\",\n    \"emails\": [\n      \"<string>\",\n      \"<string>\"\n    ],\n    \"fax\": \"<string>\",\n    \"first_name\": \"<string>\",\n    \"grace_period\": \"<integer>\",\n    \"due_in_days\": \"<integer>\",\n    \"group_id\": \"<integer>\",\n    \"id\": \"<long>\",\n    \"info_1\": \"<string>\",\n    \"info_2\": \"<string>\",\n    \"internet\": \"<string>\",\n    \"login_id\": \"<long>\",\n    \"mobile\": \"<string>\",\n    \"note\": \"<string>\",\n    \"number\": \"<string>\",\n    \"payment_options\": 1,\n    \"personal\": false,\n    \"phone_1\": \"<string>\",\n    \"phone_2\": \"<string>\",\n    \"postbox\": \"<string>\",\n    \"postbox_city\": \"<string>\",\n    \"postbox_state\": \"<string>\",\n    \"postbox_country\": \"<string>\",\n    \"postbox_zip_code\": \"<string>\",\n    \"sale_price_level\": \"SALEPRICE6\",\n    \"salutation\": 0,\n    \"sepa_agreement\": \"BASIC\",\n    \"sepa_agreement_date\": \"<date>\",\n    \"sepa_mandate_reference\": \"<string>\",\n    \"since_date\": \"<date>\",\n    \"street\": \"<string>\",\n    \"suffix_1\": \"<string>\",\n    \"suffix_2\": \"<string>\",\n    \"tax_number\": \"<string>\",\n    \"court\": \"<string>\",\n    \"court_registry_number\": \"<string>\",\n    \"tax_options\": \"nStbIm\",\n    \"title\": \"<string>\",\n    \"archived\": \"<boolean>\",\n    \"vat_identifier\": \"<string>\",\n    \"zip_code\": \"<string>\",\n    \"document_pdf_type\": \"default\",\n    \"buyer_reference\": \"<string>\",\n    \"foreign_supplier_number\": \"<string>\"\n  },\n  \"discount\": null,\n  \"discount_type\": null,\n  \"document_date\": \"<date>\",\n  \"due_date\": \"<date>\",\n  \"edited_at\": \"<dateTime>\",\n  \"external_id\": null,\n  \"replica_url\": null,\n  \"grace_period\": \"<integer>\",\n  \"due_in_days\": \"<integer>\",\n  \"id\": \"<long>\",\n  \"is_acceptable_on_public_domain\": false,\n  \"is_archive\": false,\n  \"is_draft\": \"<boolean>\",\n  \"is_replica\": false,\n  \"is_oss\": false,\n  \"item_notes\": [\n    \"<string>\",\n    \"<string>\"\n  ],\n  \"items\": [\n    {\n      \"number\": null,\n      \"description\": null,\n      \"document_note\": \"<string>\",\n      \"quantity\": 1,\n      \"quantity_str\": \"<string>\",\n      \"unit\": null,\n      \"type\": \"POSITION\",\n      \"position\": \"<integer>\",\n      \"single_price_net\": null,\n      \"single_price_gross\": \"<float>\",\n      \"vat_percent\": 0,\n      \"discount\": null,\n      \"discount_type\": null,\n      \"position_id\": null,\n      \"total_price_net\": \"<float>\",\n      \"total_price_gross\": \"<float>\",\n      \"total_vat\": \"<float>\",\n      \"serial_number_id\": \"<string>\",\n      \"serial_number\": \"<string>\",\n      \"booking_account\": null,\n      \"export_cost_1\": null,\n      \"export_cost_2\": null,\n      \"cost_price_net\": null,\n      \"cost_price_total\": \"<float>\",\n      \"cost_price_charge\": \"<float>\",\n      \"cost_price_charge_type\": \"PERCENT\",\n      \"itemType\": \"UNDEFINED\",\n      \"id\": \"<long>\"\n    },\n    {\n      \"number\": null,\n      \"description\": null,\n      \"document_note\": \"<string>\",\n      \"quantity\": 1,\n      \"quantity_str\": \"<string>\",\n      \"unit\": null,\n      \"type\": \"POSITION\",\n      \"position\": \"<integer>\",\n      \"single_price_net\": null,\n      \"single_price_gross\": \"<float>\",\n      \"vat_percent\": 0,\n      \"discount\": null,\n      \"discount_type\": null,\n      \"position_id\": null,\n      \"total_price_net\": \"<float>\",\n      \"total_price_gross\": \"<float>\",\n      \"total_vat\": \"<float>\",\n      \"serial_number_id\": \"<string>\",\n      \"serial_number\": \"<string>\",\n      \"booking_account\": null,\n      \"export_cost_1\": null,\n      \"export_cost_2\": null,\n      \"cost_price_net\": null,\n      \"cost_price_total\": \"<float>\",\n      \"cost_price_charge\": \"<float>\",\n      \"cost_price_charge_type\": \"PERCENT\",\n      \"itemType\": \"UNDEFINED\",\n      \"id\": \"<long>\"\n    }\n  ],\n  \"last_postbox_id\": \"<long>\",\n  \"login_id\": \"<long>\",\n  \"number\": null,\n  \"order_number\": \"\",\n  \"buyer_reference\": \"\",\n  \"paid_amount\": \"<integer>\",\n  \"paid_at\": \"<date>\",\n  \"pdf_pages\": \"<integer>\",\n  \"pdf_template\": \"<string>\",\n  \"project_id\": null,\n  \"recurring_options\": {\n    \"next_date\": \"<date>\",\n    \"frequency\": \"MONTHLY\",\n    \"frequency_special\": null,\n    \"interval\": 1,\n    \"end_date_or_count\": null,\n    \"status\": \"WAITING\",\n    \"as_draft\": false,\n    \"is_notify\": false,\n    \"send_as\": null,\n    \"is_sign\": false,\n    \"is_paid\": false,\n    \"paid_date_option\": \"created_date\",\n    \"is_sepa\": false,\n    \"sepa_local_instrument\": null,\n    \"sepa_sequence_type\": null,\n    \"sepa_reference\": null,\n    \"sepa_remittance_information\": null,\n    \"target_type\": \"INVOICE\"\n  },\n  \"ref_id\": null,\n  \"root_id\": null,\n  \"service_date\": {\n    \"type\": \"SERVICE\",\n    \"date\": \"<date>\",\n    \"date_from\": \"<date>\",\n    \"date_to\": \"<date>\",\n    \"text\": null\n  },\n  \"shipping_country\": null,\n  \"status\": null,\n  \"text\": \"<string>\",\n  \"text_prefix\": \"<string>\",\n  \"text_tax\": null,\n  \"title\": null,\n  \"type\": \"INVOICE\",\n  \"use_shipping_address\": false,\n  \"vat_country\": null,\n  \"vat_id\": \"\",\n  \"fulfillment_country\": null,\n  \"vat_option\": null,\n  \"file_format_config\": [\n    {\n      \"type\": \"xrechnung2_2_xml\"\n    },\n    {\n      \"type\": \"xrechnung3_0_xml\"\n    }\n  ]\n}"
    },
    {
      "name": "Invalid target document type",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/documents/:id/:type?pdf_template=DE",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            ":type"
          ],
          "query": [
            {
              "key": "pdf_template",
              "value": "DE",
              "description": "The ID of the printer template to use. Defaults to 'DE' if not given."
            }
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "type"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Too Many Requests",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/documents/:id/:type?pdf_template=DE",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            ":type"
          ],
          "query": [
            {
              "key": "pdf_template",
              "value": "DE",
              "description": "The ID of the printer template to use. Defaults to 'DE' if not given."
            }
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "type"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}