Lua Requires Chilkat v11.0.0+
Lua
Datev - Upload File (Transfer a file to DATEV data center)
See more Datev Examples
Demonstrates how to transfer a file to the DATEV data center.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- Implements the following CURL command:
-- curl --request POST \
-- --url "https://accounting-extf-files.api.datev.de/platform-sandbox/v3/clients/REPLACE_CLIENT-ID/extf-files/import" \
-- --header "Authorization: Bearer REPLACE_BEARER_TOKEN" \
-- --header "X-Datev-Client-ID: clientId" \
-- --header "accept: application/json;charset=utf-8" \
-- --header "content-type: application/octet-stream" \
-- --header "Filename: EXTF_BS_20200101_1.csv" \
-- --header "Reference-Id: Buchungsstapel_Verkäufe_2020_01_Nr_001" \
-- --header "Client-Application-Version: 2.0c" \
-- --data-binary "@REPLACE_BODY"
-- Use the following online tool to generate HTTP code from a CURL command
-- Convert a cURL Command to HTTP Source Code
local bdRequestBody = chilkat.BinData.new()
local success = bdRequestBody:load_file("c:/temp/EXTF_BS_20200101_1.csv")
if not success then
print("Failed to load the csv file.")
return
end
http:set_request_header("accept", "application/json;charset=utf-8")
http:set_request_header("X-Datev-Client-ID", "clientId")
http:set_request_header("Client-Application-Version", "2.0c")
http:set_request_header("Filename", "EXTF_BS_20200101_1.csv")
http:set_request_header("Reference-Id", "Buchungsstapel_Verkäufe_2020_01_Nr_001")
-- Adds the "Authorization: Bearer REPLACE_BEARER_TOKEN" header.
http.auth_token = "REPLACE_BEARER_TOKEN"
local resp = chilkat.HttpResponse.new()
local url = "https://accounting-extf-files.api.datev.de/platform-sandbox/v3/clients/DATEV_USER_ID/extf-files/import"
success = http:http_bd("POST", url, bdRequestBody, "application/octet-stream", resp)
if not success then
print(http.last_error_text)
return
end
print(resp.status_code)
print(resp.body_str)