Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) SII POST boleta.electronica.envioAlmacenamiento de un conjunto de boletas en el SII For more information, see https://www4c.sii.cl/bolcoreinternetui/api/
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] # Implements the following CURL command: # curl -X POST "https://pangal.sii.cl/recursos/v1/boleta.electronica.envio" -H "accept: application/json" # -H "User-Agent: Mozilla/4.0 ( compatible; PROG 1.0; Windows NT)" # -H "Cookie: YZVQNQY4J5DT9" -H "Content-Type: multipart/form-data" # -F "rutSender=1234" -F "dvSender=xyz" -F "rutCompany=9999" -F "dvCompany=abc" # -F "archivo=@starfish20.jpg;type=image/jpeg" # Use the following online tool to generate HTTP code from a CURL command # Convert a cURL Command to HTTP Source Code set req [new_CkHttpRequest] CkHttpRequest_put_HttpVerb $req "POST" CkHttpRequest_put_Path $req "/recursos/v1/boleta.electronica.envio" CkHttpRequest_put_ContentType $req "multipart/form-data" CkHttpRequest_AddParam $req "rutSender" "66666666" CkHttpRequest_AddParam $req "dvSender" "6" CkHttpRequest_AddParam $req "rutCompany" "60803000" CkHttpRequest_AddParam $req "dvCompany" "K" # Add an XML file that contains something like this: # <?xml version="1.0" encoding="ISO-8859-1"?> # <EnvioBOLETA version="1.0" xmlns="http://www.sii.cl/SiiDte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sii.cl/SiiDte EnvioBOLETA_v11.xsd"> # <SetDTE ID="SetDocB0T39_20201103_131999"> # <Caratula version="1.0"> # ... set xmlStr "..." set success [CkHttpRequest_AddStringForUpload2 $req "archivo" "envioBoleta.xml" $xmlStr "ISO-8859-1" "text/xml"] CkHttpRequest_AddHeader $req "Expect" "100-continue" CkHttpRequest_AddHeader $req "User-Agent" "Mozilla/4.0 ( compatible; PROG 1.0; Windows NT)" CkHttpRequest_AddHeader $req "Cookie" "TOKEN=YZVQNQY4J5DT9" CkHttpRequest_AddHeader $req "accept" "application/json" CkHttpRequest_AddHeader $req "Content-Type" "multipart/form-data" # For debugging, you can save the exact HTTP request sent and response received # to a session log file: CkHttp_put_SessionLogFilename $http "someDir/sessionLog.txt" # Use one of the following domains, depending on the environment: # pangal.sii.cl - Certification Environment # rahue.sii.cl - Production Environment # resp is a CkHttpResponse set resp [CkHttp_SynchronousRequest $http "pangal.sii.cl" 443 1 $req] if {[CkHttp_get_LastMethodSuccess $http] == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkHttpRequest $req exit } set sbResponseBody [new_CkStringBuilder] CkHttpResponse_GetBodySb $resp $sbResponseBody set jResp [new_CkJsonObject] CkJsonObject_LoadSb $jResp $sbResponseBody CkJsonObject_put_EmitCompact $jResp 0 puts "Response Body:" puts [CkJsonObject_emit $jResp] set respStatusCode [CkHttpResponse_get_StatusCode $resp] puts "Response Status Code = $respStatusCode" if {$respStatusCode >= 400} then { puts "Response Header:" puts [CkHttpResponse_header $resp] puts "Failed." delete_CkHttpResponse $resp delete_CkHttp $http delete_CkHttpRequest $req delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp exit } delete_CkHttpResponse $resp # Sample JSON response: # (Sample code for parsing the JSON response is shown below) # { # "rut_emisor": "45000054-K", # "rut_envia": "83154595-0", # "trackid": 1014, # "fecha_recepcion": "2020-09-01 20:30:10", # "estado": "REC", # "file": "boleta-2020-09-01-001.xml" # } # Sample code for parsing the JSON response... # Use the following online tool to generate parsing code from sample JSON: # Generate Parsing Code from JSON set rut_emisor [CkJsonObject_stringOf $jResp "rut_emisor"] set rut_envia [CkJsonObject_stringOf $jResp "rut_envia"] set trackid [CkJsonObject_IntOf $jResp "trackid"] set fecha_recepcion [CkJsonObject_stringOf $jResp "fecha_recepcion"] set estado [CkJsonObject_stringOf $jResp "estado"] set file [CkJsonObject_stringOf $jResp "file"] delete_CkHttp $http delete_CkHttpRequest $req delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.