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
(Objective-C) SII POST boleta.electronica.envioAlmacenamiento de un conjunto de boletas en el SII For more information, see https://www4c.sii.cl/bolcoreinternetui/api/
#import <CkoHttp.h> #import <CkoHttpRequest.h> #import <NSString.h> #import <CkoHttpResponse.h> #import <CkoStringBuilder.h> #import <CkoJsonObject.h> // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkoHttp *http = [[CkoHttp alloc] init]; BOOL success; // 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 CkoHttpRequest *req = [[CkoHttpRequest alloc] init]; req.HttpVerb = @"POST"; req.Path = @"/recursos/v1/boleta.electronica.envio"; req.ContentType = @"multipart/form-data"; [req AddParam: @"rutSender" value: @"66666666"]; [req AddParam: @"dvSender" value: @"6"]; [req AddParam: @"rutCompany" value: @"60803000"]; [req AddParam: @"dvCompany" value: @"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"> // ... NSString *xmlStr = @"..."; success = [req AddStringForUpload2: @"archivo" filename: @"envioBoleta.xml" strData: xmlStr charset: @"ISO-8859-1" contentType: @"text/xml"]; [req AddHeader: @"Expect" value: @"100-continue"]; [req AddHeader: @"User-Agent" value: @"Mozilla/4.0 ( compatible; PROG 1.0; Windows NT)"]; [req AddHeader: @"Cookie" value: @"TOKEN=YZVQNQY4J5DT9"]; [req AddHeader: @"accept" value: @"application/json"]; [req AddHeader: @"Content-Type" value: @"multipart/form-data"]; // For debugging, you can save the exact HTTP request sent and response received // to a session log file: 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 CkoHttpResponse *resp = [http SynchronousRequest: @"pangal.sii.cl" port: [NSNumber numberWithInt: 443] ssl: YES req: req]; if (http.LastMethodSuccess == NO) { NSLog(@"%@",http.LastErrorText); return; } CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init]; [resp GetBodySb: sbResponseBody]; CkoJsonObject *jResp = [[CkoJsonObject alloc] init]; [jResp LoadSb: sbResponseBody]; jResp.EmitCompact = NO; NSLog(@"%@",@"Response Body:"); NSLog(@"%@",[jResp Emit]); int respStatusCode = [resp.StatusCode intValue]; NSLog(@"%@%d",@"Response Status Code = ",respStatusCode); if (respStatusCode >= 400) { NSLog(@"%@",@"Response Header:"); NSLog(@"%@",resp.Header); NSLog(@"%@",@"Failed."); return; } // 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 NSString *rut_emisor = [jResp StringOf: @"rut_emisor"]; NSString *rut_envia = [jResp StringOf: @"rut_envia"]; int trackid = [[jResp IntOf: @"trackid"] intValue]; NSString *fecha_recepcion = [jResp StringOf: @"fecha_recepcion"]; NSString *estado = [jResp StringOf: @"estado"]; NSString *file = [jResp StringOf: @"file"]; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.