Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_BdRequestBody
oleobject loo_Resp
string ls_Url

li_Success = 0

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

loo_Http = create oleobject
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

// 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

loo_BdRequestBody = create oleobject
li_rc = loo_BdRequestBody.ConnectToNewObject("Chilkat.BinData")

li_Success = loo_BdRequestBody.LoadFile("c:/temp/EXTF_BS_20200101_1.csv")
if li_Success <> 1 then
    Write-Debug "Failed to load the csv file."
    destroy loo_Http
    destroy loo_BdRequestBody
    return
end if

loo_Http.SetRequestHeader("accept","application/json;charset=utf-8")
loo_Http.SetRequestHeader("X-Datev-Client-ID","clientId")
loo_Http.SetRequestHeader("Client-Application-Version","2.0c")
loo_Http.SetRequestHeader("Filename","EXTF_BS_20200101_1.csv")
loo_Http.SetRequestHeader("Reference-Id","Buchungsstapel_Verkäufe_2020_01_Nr_001")
// Adds the "Authorization: Bearer REPLACE_BEARER_TOKEN" header.
loo_Http.AuthToken = "REPLACE_BEARER_TOKEN"

loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

ls_Url = "https://accounting-extf-files.api.datev.de/platform-sandbox/v3/clients/DATEV_USER_ID/extf-files/import"
li_Success = loo_Http.HttpBd("POST",ls_Url,loo_BdRequestBody,"application/octet-stream",loo_Resp)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_BdRequestBody
    destroy loo_Resp
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr


destroy loo_Http
destroy loo_BdRequestBody
destroy loo_Resp