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
(PowerBuilder) SII POST boleta.electronica.envioAlmacenamiento de un conjunto de boletas en el SII For more information, see https://www4c.sii.cl/bolcoreinternetui/api/
integer li_rc oleobject loo_Http integer li_Success oleobject loo_Req string ls_XmlStr oleobject loo_Resp oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode string ls_Rut_emisor string ls_Rut_envia integer li_Trackid string ls_Fecha_recepcion string ls_Estado string ls_File // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 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 -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 loo_Req = create oleobject // Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0 li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest") loo_Req.HttpVerb = "POST" loo_Req.Path = "/recursos/v1/boleta.electronica.envio" loo_Req.ContentType = "multipart/form-data" loo_Req.AddParam("rutSender","66666666") loo_Req.AddParam("dvSender","6") loo_Req.AddParam("rutCompany","60803000") loo_Req.AddParam("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"> // ... ls_XmlStr = "..." li_Success = loo_Req.AddStringForUpload2("archivo","envioBoleta.xml",ls_XmlStr,"ISO-8859-1","text/xml") loo_Req.AddHeader("Expect","100-continue") loo_Req.AddHeader("User-Agent","Mozilla/4.0 ( compatible; PROG 1.0; Windows NT)") loo_Req.AddHeader("Cookie","TOKEN=YZVQNQY4J5DT9") loo_Req.AddHeader("accept","application/json") loo_Req.AddHeader("Content-Type","multipart/form-data") // For debugging, you can save the exact HTTP request sent and response received // to a session log file: loo_Http.SessionLogFilename = "someDir/sessionLog.txt" // Use one of the following domains, depending on the environment: // pangal.sii.cl - Certification Environment // rahue.sii.cl - Production Environment loo_Resp = loo_Http.SynchronousRequest("pangal.sii.cl",443,1,loo_Req) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Req return end if loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbResponseBody) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Resp.StatusCode Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Resp.Header Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_Req destroy loo_SbResponseBody destroy loo_JResp return end if destroy loo_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 ls_Rut_emisor = loo_JResp.StringOf("rut_emisor") ls_Rut_envia = loo_JResp.StringOf("rut_envia") li_Trackid = loo_JResp.IntOf("trackid") ls_Fecha_recepcion = loo_JResp.StringOf("fecha_recepcion") ls_Estado = loo_JResp.StringOf("estado") ls_File = loo_JResp.StringOf("file") destroy loo_Http destroy loo_Req destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.