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) hacienda.go.cr Recepción de comprobantes electrónicos y respuestas del receptor.Comprobantes Electrónicos API version v1 -- Recepción de comprobantes electrónicos y respuestas del receptor. For more information, see https://www.hacienda.go.cr/ATV/ComprobanteElectronico/docs/esquemas/2016/v4.1/comprobantes-electronicos-api.html#recepcion_post
integer li_rc oleobject loo_Http integer li_Success oleobject loo_BdSignedXml oleobject loo_Json oleobject loo_JsonToken integer li_Success oleobject loo_Resp // 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 -H "Content-Type: application / json" \ // -H 'authorization: Bearer {access_token}' \ // -d '{ // "clave": "50601011600310112345600100010100000000011999999999", // "fecha": "2016-01-01T00:00:00-0600", // "emisor": { // "tipoIdentificacion": "02", // "numeroIdentificacion": "003101123456" // }, // "receptor": { // "tipoIdentificacion": "02", // "numeroIdentificacion": "003101123456" // }, // "comprobanteXml": "PD94..." // }' https://api.comprobanteselectronicos.go.cr/recepcion/v1/recepcion // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "clave": "50601011600310112345600100010100000000011999999999", // "fecha": "2016-01-01T00:00:00-0600", // "emisor": { // "tipoIdentificacion": "02", // "numeroIdentificacion": "003101123456" // }, // "receptor": { // "tipoIdentificacion": "02", // "numeroIdentificacion": "003101123456" // }, // "comprobanteXml": "PD94b..." // } // Load the previously signed XML. loo_BdSignedXml = create oleobject // Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 li_rc = loo_BdSignedXml.ConnectToNewObject("Chilkat.BinData") li_Success = loo_BdSignedXml.LoadFile("someDir/signed.xml") if li_Success = 0 then Write-Debug "Failed to load the XAdES signed XML." destroy loo_Http destroy loo_BdSignedXml return end if loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("clave","50601011600310112345600100010100000000011999999999") loo_Json.UpdateString("fecha","2016-01-01T00:00:00-0600") loo_Json.UpdateString("emisor.tipoIdentificacion","02") loo_Json.UpdateString("emisor.numeroIdentificacion","003101123456") loo_Json.UpdateString("receptor.tipoIdentificacion","02") loo_Json.UpdateString("receptor.numeroIdentificacion","003101123456") // Add the base64 encoded representation of the signed XML. loo_Json.UpdateString("comprobanteXml",loo_BdSignedXml.GetEncoded("base64")) // Load our previously obtained OAuth2 access token. loo_JsonToken = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_JsonToken.LoadFile("qa_data/tokens/hacienda_cr.json") if li_Success <> 1 then Write-Debug "Failed to load constantContact.json" destroy loo_Http destroy loo_BdSignedXml destroy loo_Json destroy loo_JsonToken return end if // Adds the "Authorization: Bearer {access_token}" header. loo_Http.AuthToken = loo_JsonToken.StringOf("access_token") loo_Http.SetRequestHeader("Content-Type","application / json") loo_Resp = loo_Http.PostJson3("https://api.comprobanteselectronicos.go.cr/recepcion/v1/recepcion","application/json",loo_Json) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_BdSignedXml destroy loo_Json destroy loo_JsonToken return end if // A 201 status code indicates success. Write-Debug "Response status code: " + string(loo_Resp.StatusCode) Write-Debug "Response body:" Write-Debug loo_Resp.BodyStr destroy loo_Resp destroy loo_Http destroy loo_BdSignedXml destroy loo_Json destroy loo_JsonToken |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.