DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Variant vBdRequestBody
Handle hoBdRequestBody
Variant vResp
Handle hoResp
String sUrl
String sTemp1
Integer iTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// 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
Get Create (RefClass(cComChilkatBinData)) To hoBdRequestBody
If (Not(IsComObjectCreated(hoBdRequestBody))) Begin
Send CreateComObject of hoBdRequestBody
End
Get ComLoadFile Of hoBdRequestBody "c:/temp/EXTF_BS_20200101_1.csv" To iSuccess
If (iSuccess <> True) Begin
Showln "Failed to load the csv file."
Procedure_Return
End
Send ComSetRequestHeader To hoHttp "accept" "application/json;charset=utf-8"
Send ComSetRequestHeader To hoHttp "X-Datev-Client-ID" "clientId"
Send ComSetRequestHeader To hoHttp "Client-Application-Version" "2.0c"
Send ComSetRequestHeader To hoHttp "Filename" "EXTF_BS_20200101_1.csv"
Send ComSetRequestHeader To hoHttp "Reference-Id" "Buchungsstapel_Verkäufe_2020_01_Nr_001"
// Adds the "Authorization: Bearer REPLACE_BEARER_TOKEN" header.
Set ComAuthToken Of hoHttp To "REPLACE_BEARER_TOKEN"
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Move "https://accounting-extf-files.api.datev.de/platform-sandbox/v3/clients/DATEV_USER_ID/extf-files/import" To sUrl
Get pvComObject of hoBdRequestBody to vBdRequestBody
Get pvComObject of hoResp to vResp
Get ComHttpBd Of hoHttp "POST" sUrl vBdRequestBody "application/octet-stream" vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln iTemp1
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
End_Procedure