API Facturación Electrónica
  • Introducción
  • Cuotas y límites
  • Primeros Pasos
    • Consideraciones Importantes
    • Manual Operativo de la Plataforma
    • Generar X-API-KEY
    • Librerías
    • Estructura de los datos
      • Listas de códigos
        • Responsable de
        • Campos generales (Facturas, notas)
        • Códigos de moneda
        • Códigos de forma de pago
        • Códigos de actividades económicas
        • Códigos de país
        • Códigos de región
        • Códigos de ciudad
        • Códigos de unidades de medida
      • Factura
      • Documento soporte
      • Nota débito
      • Nota crédito
      • Nota de ajuste
    • Formatos PDF
  • Errores y rechazos
    • Códigos de rechazo y advertencia de la DIAN
      • Factura
      • Nota débito
      • Nota crédito
    • Errores comunes
  • Modo Pruebas
    • Facturas
      • Enviar factura en modo pruebas
    • Notas débito
      • Enviar nota débito en modo pruebas
    • Notas crédito
      • Enviar nota crédito en modo pruebas
    • Documento soporte
      • Enviar documento soporte en modo pruebas
    • Nota de ajuste
      • Enviar nota de ajuste en modo pruebas
  • Modo Habilitación
    • Facturas
      • Enviar factura para set de pruebas
    • Notas débito
      • Enviar nota débito para set de pruebas
    • Notas crédito
      • Enviar nota crédito para set de pruebas
  • Modo Producción
    • Facturas
      • Enviar factura
    • Notas débito
      • Enviar nota débito
    • Notas crédito
      • Enviar nota crédito
    • Documento soporte
      • Enviar documento soporte
    • Nota de ajuste
      • Enviar nota de ajuste
    • Resoluciones
      • Consultar resoluciones
  • Archivo Plano (.CSV)
    • Consideraciones sobre el archivo plano
    • Estructura del archivo plano
      • Factura
      • Nota débito
      • Nota crédito
    • Importar archivo plano
Con tecnología de GitBook
En esta página
  • Enviar factura
  • Código de ejemplo

¿Te fue útil?

  1. Modo Habilitación
  2. Facturas

Enviar factura para set de pruebas

Modo habilitación

Enviar factura

POST https://isv.aliaddo.net/api/v1/public/documents/invoice/habilitation/{testSetId}

Este método envía una factura para set de pruebas en modo habilitación.

Path Parameters

Name
Type
Description

testSetId

string

Identificador del set de pruebas

version

string

Versión de la API

Headers

Name
Type
Description

x-api-key

string

Token generado previamente para autorizarse

Request Body

Name
Type
Description

isvInvoice

object

Objeto de la factura

{
	"id": "string",
	"code": "string",
	"mode": "string",
	"format": "string",
	"emailSender": "string",
	"testSetId": "string",
	"prefix": "string",
	"consecutive": 0,
	"status": "string",
	"statusDate": "2020-01-30T00:00:00",
	"sequence": "string",
	"externalNumber": "string",
	"currencyCode": "string",
	"currencyRate": 0,
	"date": "2020-01-30T00:00:00",
	"dateDue": "2020-01-31T00:00:00",
	"dateStart": "2020-01-30T00:00:00",
	"dateEnd": "2020-01-31T00:00:00",
	"typeOfOperation": "string",
	"typeOfOperation": "string",
	"incoterms": "string",
	"deliveryTerms": "string",
	"terms": "string",
	"remark": "string",
	"observation": "string",
	"cufe": "string",
	"qr": "string",
	"urlPdf": "string",
	"urlXmlDocument": "string",
	"urlXmlDocumentZip": "string",
	"urlXmlApplicationResponse": "string",
	"urlXmlAttachedDocument": "string",
	"UrlPdfEncoded": "string",
	"UrlXmlEncoded": "string",
	"dianDeliveryStatus": "string",
	"dianState": "string",
	"dianStateReason": "string",
	"dianStateDate": "0001-01-01T00:00:00",
	"sentEmail": false,
	"sentEmailAt": "0001-01-01T00:00:00",
	"termDay": 0,
	"paymentMeanCode": "string",
	"rejectReason": "string",
	"hasNotesDb": false,
	"hasNotesCr": false,
	"branch": {
		"name": "string",
		"address": "string",
		"phone": "string",
		"countryCode": "string",
		"countryName": "string",
		"departamentCode": "string",
		"departamentName": "string",
		"cityCode": "string",
		"cityName": "string"
	},
	"resolution": {
		"resolutionKey": "string",
		"resolutionPrefix": "string",
		"resolutionNumber": 0,
		"resolutionRangeInitial": 0,
		"resolutionRangeFinal": 0,
		"resolutionValidFrom": "2019-01-19T00:00:00",
		"resolutionValidUntil": "2030-01-19T00:00:00"
	},
	"customer": {
		"companyName": "string",
		"personType": "string",
		"regimeType": "string",
		"firstName": "string",
		"lastName": "string",
		"identification": "string",
		"digitCheck": "string",
		"identificationTypeCode": "string",
		"email": "string",
		"phone": "string",
		"merchantRegistration": "string",
		"responsibilities": "string",
		"economicActivities": "string",
		"billingAddress": "string",
		"billingCountryName": "string",
		"billingCountryCode": "string",
		"billingRegionName": "string",
		"billingRegionCode": "string",
		"billingCityName": "string",
		"billingCityCode": "string",
		"billingPostalCode": "string",
		"billingNeighborhood": "string",
		"billingPhone": "string",
		"billingContactName": "string",
		"shippingAddress": "string",
		"shippingCountryName": "string",
		"shippingCountryCode": "string",
		"shippingRegionName": "string",
		"shippingRegionCode": "string",
		"shippingCityName": "string",
		"shippingCityCode": "string",
		"shippingPostalCode": "string",
		"shippingNeighborhood": "string",
		"shippingPhone": "string",
		"shippingContactName": "string"
	},
	"invoiceDetails": [{
		"standardType": "string",
		"standardCode": "string",
		"itemCode": "string",
		"itemName": "string",
		"itemModel": "string",
		"description": "string",
		"brandName": "string",
		"itemCodeSupplier": "string",
		"isPresent": false,
		"unitMeasurementCode": "string",
		"unitMeasurementName": "string",
		"price": 0,
		"quantity": 0,
		"discountAmount": 0,
		"chargeAmount": 0,
		"subTotal": 0,
		"priceWithAllowanceCharge": 0,
		"totalWithAllowanceCharge": 0,
		"discounts": [{
			"name": "string",
			"type": "string",
			"rate": 0,
			"amount": 0
		}],
		"charges": [{
			"name": "string",
			"type": "string",
			"rate": 0,
			"amount": 0
		}],
		"taxes": [{
			"name": "string",
			"code": "string",
			"type": "string",
			"rate": 0,
			"amount": 0,
			"base": 0
		}],
		"withholdings": [{
			"name": "string",
			"code": "string",
			"type": "string",
			"rate": 0,
			"amount": 0,
			"base": 0
		}],
		"isvMandante": {
			"name": "string",
			"identification": "string",
			"digitCheck": "string",
			"identificationTypeCode": "string"
		}
	}],
	"totals": {
		"amount": 0,
		"prepaymentAmount": 0,
		"taxesAmount": 0,
		"withholdingAmount": 0,
		"discountsAmount": 0,
		"chargesAmount": 0
	},
	"discounts": [{
		"name": "string",
		"type": "string",
		"rate": 0,
		"amount": 0
	}],
	"charges": [{
		"name": "string",
		"type": "string",
		"rate": 0,
		"amount": 0
	}],
	"customFields": [{
		"key": "string",
		"value": "string"
	}],
	"createdAt": "0001-01-01T00:00:00",
	"updatedAt": "0001-01-01T00:00:00",
	"isDue": false
}
No se encontraron resultados de acuerdo a los criterios de busqueda
No se han enviado los tipos de datos requeridos
No esta autorizado para realizar el requerimiento a este metodo, debe enviar el token generado en el token
Se ha producido un incidente al validar el documento

Código de ejemplo

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using RestSharp;

namespace ConsoleApp1
{
    public class Program
    {
        public static void Main()
        {
            /**
              /invoice/habilitation/{testSetId}:
              - Enviar una factura para set de pruebas, en modo habilitación
              - Instale RestSharp via Nuget: Install-Package RestSharp -Version 106.6.10
              - Instale Newtonsoft via Nuget: Install-Package Newtonsoft.Json
             */

            // Realizar request con TestId ejemplo 4bf6673a-7a71-496e-8cfd-f7246067e4ca, cambie este TestId por el que usted generó en la DIAN para habilitarse como facturador electrónico, si va realizar pruebas de conexión a la API puede realizarlo con el que esta en este ejemplo
            // Realizar request por metodo POST
            var request = new RestRequest("/invoice/habilitation/4bf6673a-7a71-496e-8cfd-f7246067e4ca", Method.POST);
            // Limpiar parametros
            request.Parameters.Clear();
            // Adicionar cabeceras de autenticación con token Bearer generado  en el panel izquierdo
            request.AddHeader("x-api-key", "{{x-api-key}}");
            // Tipo de requerimiento formato json
            request.AddHeader("content-type", "application/json");
            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("accept", "application/json");
            request.RequestFormat = DataFormat.Json;
            // Adicionando objeto factura con resolución ejemplo
            var isvInvoice = new
        {
            code = "01",
            format = "Estandar",
            emailSender = "email@example.com",
            consecutive = 990004332,
            externalNumber = "54554",
            currencyCode = "COP",
            currencyRate = 0,
            date = "2020-1-18",
            dateDue = "2020-1-18",
            dateStart = "2020-1-18",
            dateEnd = "2020-1-20",
            typeOfOperation = "10",
            dueDiligence = "",
            incoterms = "",
            terms = "",
            remark = "",
            observation = "",
            termDay = 0,
            paymentMeanCode = "48",
            branch = new {
                name = "branch",
                address = "Cl6 Cra 66",
                phone = "7649813",
                countryCode = "CO",
                countryName = "Colombia",
                departamentCode = "25",
                departamentName = "Cundinamarca",
                cityCode = "11001",
                cityname = "Bogotá, D.c."
            },
            resolution = new
            {
                resolutionKey = "fc8eac422eba16e22ffd8c6f94b3f40a6e38162c",
                resolutionPrefix = "SETT",
                resolutionNumber = 18760000001,
                resolutionRangeInitial = 990000000,
                resolutionRangeFinal = 995000000,
                resolutionValidFrom = "2019-01-19",
                resolutionValidUntil = "2030-01-19"
            },
            customer = new
            {
                companyName = "Customer",
                personType = "1",
                regimeType = "04",
                firstName = "Customer",
                lastName = "Customer",
                identification = "000000001",
                digitCheck = "8",
                identificationTypeCode = "13",
                email = "",
                phone = "0000001",
                merchantRegistration = "",
		responsibleFor: "ZZ",
                responsibilities = "R-99-PN",
                economicActivities = "2817;3092",
                billingAddress = "KR con Calle",
                billingCountryName = "Colombia",
                billingCountryCode = "CO",
                billingRegionName = "Cundinamarca",
                billingRegionCode = "25",
                billingCityName = "Chipaque",
                billingCityCode = "25178",
                billingPostalCode = "",
                billingNeighborhood = "",
                billingPhone = "",
                billingContactName = "",
                shippingAddress = "",
                shippingCountryName = "",
                shippingCountryCode = "",
                shippingRegionName = "",
                shippingRegionCode = "",
                shippingCityName = "",
                shippingCityCode = "",
                shippingPostalCode = "",
                shippingNeighborhood = "",
                shippingPhone = "",
                shippingContactName = ""
            },
            invoiceDetails = new[]{
            new {
                standardType = "",
                standardCode = "",
                itemCode = "0001",
                itemName = "Item",
                itemModel = "",
                description = "Item prueba",
                brandName = "",
                itemCodeSupplier = "",
                isPresent = false,
                isRemmitance: false,
                remmitanceNumber: "",
                remmitanceConsecutive: "",
                remmitanceValue: 0,
                remmitanceQuantityValue: 0,
                remmitanceMeasurementUnit: "",
                unitMeasurementCode = "NIU",
                unitMeasurementName = "",
                price = 25,
                quantity = 2,
                discounts = new[]{
                    new {
                        name = "",
                        type = "V",
                        rate = 1,
                        amount = 1
                    }
                },
                charges = new[]{
                    new {
                        name = "",
                        code = "01",
                        type = "V",
                        rate = 10,
                        amount = 10
                    }
                },
                taxes = new[]{
                    new {
                        name = "Iva",
                        code = "01",
                        type = "P",
                        rate = 20,
                        amount = 6.46
                    }
                },
                withholdings = new[]{
                    new {
                        name = "ReteFuente",
                        code = "06",
                        type = "P",
                        rate = 10,
                        amount = 3.4
                    }
                },
                isvMandante = new
                {
                    name = "Mandante",
                    identification = "000001",
                    digitCheck = "8",
                    identificationTypeCode = "13"
                }
            }
        },
            totals = new
            {
                amount = 68,
                prepaymentAmount = 0
            },
            discounts = new[]
            {
                new {
                    name = "",
                    type = "",
                    rate = 0,
                    amount = 0
                }
            },
            charges = new[]
            {
                new {
                    name = "",
                    type = "V",
                    rate = 10,
                    amount = 10
                }
            },
            customFields = new[]
            {
                new KeyValuePair<string, string>("NombreCampo", "ValorCampo")
            }
        };
        request.AddParameter("application/json", JsonConvert.SerializeObject(isvInvoice), ParameterType.RequestBody);
        
            // Ejecutar request
            var client = new RestClient("https://isv.aliaddo.net/api/v1/public/documents");
        var response = client.Execute(request);

        // Mostrar respuesta
        Console.WriteLine((int) response.StatusCode);
            Console.WriteLine(response.Content);
        }
    }
}
/*
 * /invoice/habilitation/{testSetId}:
 * - Editar una factura para set de pruebas, en modo habilitación
 * - Realizar request con TestId ejemplo 4bf6673a-7a71-496e-8cfd-f7246067e4ca, cambie este TestId por el que
 * usted generó en la DIAN para habilitarse como facturador electrónico, si va realizar pruebas de conexión a
 * la API puede realizarlo con el que esta en este ejemplo
 * - Realizar request por metodo POST
 */
fetch('https://isv.aliaddo.net/api/v1/public/documents/invoice/habilitation/4bf6673a-7a71-496e-8cfd-f7246067e4ca', {
  method: 'POST',
  // Crear objeto factura con resolución de ejemplo
  body: JSON.stringify({
    "code": "01",
    "format": "Estandar",
    "emailSender": "",
    "consecutive": "990004322",
    "externalNumber": "",
    "currencyCode": "COP",
    "currencyRate": 0,
    "date": "2020-1-23",
    "dateDue": "2020-1-29",
    "dateStart": "2020-1-23",
    "dateEnd": "2020-1-29",
    "typeOfOperation": "10",
    "dueDiligence": "",
    "incoterms": "",
    "deliveryTerms": "",
    "terms": "",
    "remark": "",
    "observation": "",
    "termDay": 0,
    "paymentMeanCode": "48",
    "branch": {
      "name": "",
      "address": "",
      "phone": "",
      "countryCode": "",
      "countryName": "",
      "departamentCode": "",
      "departamentName": "",
      "cityCode": "",
      "cityName": ""
    },
    "resolution": {
      "resolutionKey": "fc8eac422eba16e22ffd8c6f94b3f40a6e38162c",
      "resolutionPrefix": "SETP",
      "resolutionNumber": "18760000001",
      "resolutionRangeInitial": "990000000",
      "resolutionRangeFinal": "995000000",
      "resolutionValidFrom": "2019-01-19",
      "resolutionValidUntil": "2030-01-19"
    },
    "customer": {
      "companyName": "Customer",
      "personType": "1",
      "regimeType": "04",
      "firstName": "Customer",
      "lastName": "Customer",
      "identification": "000000001",
      "digitCheck": "8",
      "identificationTypeCode": "13",
      "email": "email@email.com",
      "phone": "",
      "merchantRegistration": "",
      "responsibleFor": "ZZ",
      "responsibilities": "R-99-PN",
      "economicActivities": "2817;3092",
      "billingAddress": "KR con Calle",
      "billingCountryName": "Colombia",
      "billingCountryCode": "CO",
      "billingRegionName": "Cundinamarca",
      "billingRegionCode": "25",
      "billingCityName": "Chipaque",
      "billingCityCode": "25178",
      "billingPostalCode": "",
      "billingNeighborhood": "",
      "billingPhone": "",
      "billingContactName": "",
      "shippingAddress": "",
      "shippingCountryName": "",
      "shippingCountryCode": "",
      "shippingRegionName": "",
      "shippingRegionCode": "",
      "shippingCityName": "",
      "shippingCityCode": "",
      "shippingPostalCode": "",
      "shippingNeighborhood": "",
      "shippingPhone": "",
      "shippingContactName": ""
    },
    "invoiceDetails": [{
      "standardType": "",
      "standardCode": "",
      "itemCode": "0001",
      "itemName": "Item",
      "itemModel": "",
      "description": "Item prueba",
      "brandName": "",
      "itemCodeSupplier": "",
      "isPresent": false,
      "isRemmitance": false,
      "remmitanceNumber": "",
      "remmitanceConsecutive": "",
      "remmitanceValue": 0,
      "remmitanceQuantityValue": 0,
      "remmitanceMeasurementUnit": "",
      "unitMeasurementCode": "",
      "unitMeasurementName": "",
      "price": "1285.00",
      "quantity": "2",
      "discounts": [{
        "name": "",
        "type": "V",
        "rate": 1,
        "amount": 1
      }],
      "charges": [{
        "name": "",
        "type": "V",
        "rate": 10,
        "amount": 10
      }],
      "taxes": [{
        "name": "Iva",
        "code": "01",
        "type": "V",
        "rate": 10,
        "amount": 10
      }],
      "withholdings": [{
        "name": "ReteFuente",
        "code": "06",
        "type": "P",
        "rate": 10,
        "amount": 3.4
      }],
      "isvMandante": {
        "name": "Mandante",
        "identification": "000001",
        "digitCheck": "8",
        "identificationTypeCode": "13"
      }
    }],
    "totals": {
      "prepaymentAmount": 68,
      "amount": 0
    },
    "discounts": [{
      "name": "",
      "type": "",
      "rate": 0,
      "amount": 0
    }],
    "charges": [{
      "name": "",
      "type": "",
      "rate": 0,
      "amount": 0
    }
    ],
    "customFields": [{
      "value": "666",
      "key": "invoiceId"
    }]
  }),
  // Añadir cabeceras a la petición
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': '{{x-api-key}}'
  }
})
  // Manejar petición en caso de que haya sido exitosa o fallida
  .then(res => console.log(res.json()))
  .catch(error => console.error('Error:', error))
  .then(response => console.log('Success:', response))
/* Agregue este código a su POM
    ***** CONTENIDO DEL POM *****
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            // Clase donde se ejecuta el request
                            <mainClass>Program</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        // Agregar dependencia de UniRest para manejar los request
        <dependency>
            <groupId>com.konghq</groupId>
            <artifactId>unirest-java</artifactId>
            <version>3.1.00</version>
        </dependency>
        // Agregar dependencia de GSON para serializar los objetos de Java a JSON
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
        </dependency>
    </dependencies>
*/


// **** Clase donde se ejecuta el request ****

// Agregue las dependencias de UniRest a su POM como se indica en el código superior
import com.google.gson.*;
import kong.unirest.*;

/*
 * /invoice/{testSetId}:
 * - Enviar una factura para set de pruebas, en modo habilitación
 * - Añada las dependencias de UniRest y GSON a su POM como se muestra en el código de la parte superior
 */

public class Program {
    public static void main(String[] args) {
        // Crear objeto factura con resolución ejemplo
        JsonObject isvInvoice = new JsonObject();
        isvInvoice.addProperty("code", "01");
        isvInvoice.addProperty("format", "Estandar");
        isvInvoice.addProperty("emailSender", "");
        isvInvoice.addProperty("consecutive", 990004336);
        isvInvoice.addProperty("externalNumber", "54554");
        isvInvoice.addProperty("currencyCode", "COP");
        isvInvoice.addProperty("currencyRate", 0);
        isvInvoice.addProperty("date", "2020-1-20");
        isvInvoice.addProperty("dateDue", "2020-1-24");
        isvInvoice.addProperty("dateStart", "2020-1-20");
        isvInvoice.addProperty("dateEnd", "2020-1-24");
        isvInvoice.addProperty("typeOfOperation", "10");
        isvInvoice.addProperty("dueDiligence", "");
        isvInvoice.addProperty("incoterms", "");
        isvInvoice.addProperty("terms", "");
        isvInvoice.addProperty("remark", "");
        isvInvoice.addProperty("observation", "");
        isvInvoice.addProperty("termDay", 0);
        isvInvoice.addProperty("paymentCode", 48);

        JsonObject branchObj = new JsonObject();
        branchObj.addProperty("name", "");
        branchObj.addProperty("address", "");
        branchObj.addProperty("phone", "");
        branchObj.addProperty("countryCode", "");
        branchObj.addProperty("countryName", "");
        branchObj.addProperty("departmentCode", "");
        branchObj.addProperty("departmentName", "");
        branchObj.addProperty("cityCode", "");
        branchObj.addProperty("cityName", "");

        isvInvoice.add("branch", branchObj);

        JsonObject resolutionObj = new JsonObject();
        resolutionObj.addProperty("resolutionKey", "fc8eac422eba16e22ffd8c6f94b3f40a6e38162c");
        resolutionObj.addProperty("resolutionPrefix", "SETP");
        resolutionObj.addProperty("resolutionNumber", 18760000001f); // La f indica tipo float
        resolutionObj.addProperty("resolutionRangeInitial", 990000000);
        resolutionObj.addProperty("resolutionRangeFinal", 995000000);
        resolutionObj.addProperty("resolutionValidFrom", "2019-01-19");
        resolutionObj.addProperty("resolutionValidUntil", "2030-01-19");

        isvInvoice.add("resolution", resolutionObj);

        JsonObject customerObj = new JsonObject();
        customerObj.addProperty("companyName", "Customer");
        customerObj.addProperty("personType", "1");
        customerObj.addProperty("regimeType", "04");
        customerObj.addProperty("firstName", "Customer");
        customerObj.addProperty("lastName", "Customer");
        customerObj.addProperty("identification", "000000001");
        customerObj.addProperty("digitCheck", "8");
        customerObj.addProperty("identificationTypeCode", "13");
        customerObj.addProperty("email", "");
        customerObj.addProperty("phone", "0000001");
        customerObj.addProperty("merchantRegistration", "");
        customerObj.addProperty("responsibleFor", "ZZ");
        customerObj.addProperty("responsibilities", "R-99-PN");
        customerObj.addProperty("economicActivities", "2817;3092");
        customerObj.addProperty("billingAddress", "KR con Calle");
        customerObj.addProperty("billingCountryName", "Colombia");
        customerObj.addProperty("billingCountryCode", "CO");
        customerObj.addProperty("billingRegionName", "Cundinamarca");
        customerObj.addProperty("billingRegionCode", "25");
        customerObj.addProperty("billingCityName", "Chipaque");
        customerObj.addProperty("billingCityCode", "25178");
        customerObj.addProperty("billingPostalCode", "");
        customerObj.addProperty("billingNeighborhood", "");
        customerObj.addProperty("billingPhone", "");
        customerObj.addProperty("billingContactName", "");
        customerObj.addProperty("shippingAddress", "");
        customerObj.addProperty("shippingCountryName", "");
        customerObj.addProperty("shippingCountryCode", "");
        customerObj.addProperty("shippingRegionName", "");
        customerObj.addProperty("shippingRegionCode", "");
        customerObj.addProperty("shippingCityName", "");
        customerObj.addProperty("shippingCityCode", "");
        customerObj.addProperty("shippingPostalCode", "");
        customerObj.addProperty("shippingNeighborhood", "");
        customerObj.addProperty("shippingPhone", "");
        customerObj.addProperty("shippingContactName", "");

        isvInvoice.add("customer", customerObj);

        JsonArray invoiceDetailsArr = new JsonArray();
        JsonObject invoiceDetailsObj = new JsonObject();
        invoiceDetailsObj.addProperty("standardType", "");
        invoiceDetailsObj.addProperty("standardCode", "");
        invoiceDetailsObj.addProperty("itemCode", "0001");
        invoiceDetailsObj.addProperty("itemName", "Item");
        invoiceDetailsObj.addProperty("itemModel", "");
        invoiceDetailsObj.addProperty("description", "Item prueba");
        invoiceDetailsObj.addProperty("brandName", "");
        invoiceDetailsObj.addProperty("itemCodeSupplier", "");
        invoiceDetailsObj.addProperty("isPresent", false);
        invoiceDetailsObj.addProperty("isRemmitance", false);        
        invoiceDetailsObj.addProperty("remmitanceNumber", "");    
        invoiceDetailsObj.addProperty("remmitanceConsecutive", "");    
        invoiceDetailsObj.addProperty("remmitanceValue", 0);    
        invoiceDetailsObj.addProperty("remmitanceQuantityValue", 0);    
        invoiceDetailsObj.addProperty("remmitanceMeasurementUnit", "");   
        invoiceDetailsObj.addProperty("unitMeasurementCode", "");
        invoiceDetailsObj.addProperty("unitMeasurementName", "");
        invoiceDetailsObj.addProperty("price", 25);
        invoiceDetailsObj.addProperty("quantity", 2);
        invoiceDetailsArr.add(invoiceDetailsObj);

        JsonArray discountsArr = new JsonArray();
        JsonObject discountsObj = new JsonObject();
        discountsObj.addProperty("name", "");
        discountsObj.addProperty("type", "V");
        discountsObj.addProperty("rate", 1);
        discountsObj.addProperty("amount", 1);
        discountsArr.add(discountsObj);
        invoiceDetailsObj.add("discounts", discountsArr);

        JsonArray chargesArr = new JsonArray();
        JsonObject chargesObj = new JsonObject();
        chargesObj.addProperty("name", "");
        chargesObj.addProperty("type", "V");
        chargesObj.addProperty("rate", 10);
        chargesObj.addProperty("amount", 10);
        chargesArr.add(chargesObj);
        invoiceDetailsObj.add("charges", chargesArr);

        JsonArray taxesArr = new JsonArray();
        JsonObject taxesObj = new JsonObject();
        taxesObj.addProperty("name", "Iva");
        taxesObj.addProperty("code", "01");
        taxesObj.addProperty("type", "P");
        taxesObj.addProperty("rate", 19);
        taxesObj.addProperty("amount", 6.46);
        taxesArr.add(taxesObj);
        invoiceDetailsObj.add("taxes", taxesArr);

        JsonArray withholdingsArr = new JsonArray();
        JsonObject withholdingsObj = new JsonObject();
        withholdingsObj.addProperty("name", "ReteFuente");
        withholdingsObj.addProperty("code", "06");
        withholdingsObj.addProperty("type", "P");
        withholdingsObj.addProperty("rate", 10);
        withholdingsObj.addProperty("amount", 3.4);
        withholdingsArr.add(withholdingsObj);
        invoiceDetailsObj.add("withholdings", withholdingsArr);

        JsonObject isvMandanteObj = new JsonObject();
        isvMandanteObj.addProperty("name", "Mandante");
        isvMandanteObj.addProperty("identification", "00001");
        isvMandanteObj.addProperty("digitCheck", "8");
        isvMandanteObj.addProperty("identificationTypeCode", "13");
        invoiceDetailsObj.add("isvMandante", isvMandanteObj);

        isvInvoice.add("invoiceDetails", invoiceDetailsArr);

        JsonObject totals = new JsonObject();
        totals.addProperty("amount", 68);
        totals.addProperty("prepaymentAmount", 0);
        isvInvoice.add("totals", totals);

        JsonArray invoiceDiscountsArr = new JsonArray();
        JsonObject invoiceDiscountsObj = new JsonObject();
        invoiceDiscountsObj.addProperty("name", "");
        invoiceDiscountsObj.addProperty("type", "");
        invoiceDiscountsObj.addProperty("rate", 0);
        invoiceDiscountsObj.addProperty("amount", 0);
        invoiceDiscountsArr.add(invoiceDiscountsObj);
        isvInvoice.add("discounts", invoiceDiscountsArr);

        JsonArray invoiceChargesArr = new JsonArray();
        JsonObject invoiceChargesObj = new JsonObject();
        invoiceChargesObj.addProperty("name", "");
        invoiceChargesObj.addProperty("type", "");
        invoiceChargesObj.addProperty("rate", 0);
        invoiceChargesObj.addProperty("amount", 0);
        invoiceChargesArr.add(invoiceChargesObj);
        isvInvoice.add("discounts", invoiceChargesArr);

        JsonArray customFieldsArr = new JsonArray();
        JsonObject customFieldsObj = new JsonObject();
        customFieldsObj.addProperty("666", "invoiceId");
        customFieldsArr.add(customFieldsObj);
        isvInvoice.add("customFields", customFieldsArr);

        /*
         * - Realizar request con TestId ejemplo 4bf6673a-7a71-496e-8cfd-f7246067e4ca, cambie este TestId por el que
         * usted generó en la DIAN para habilitarse como facturador electrónico, si va realizar pruebas de conexión a
         * la API puede realizarlo con el que esta en este ejemplo
         * - Realizar request por metodo POST
         */
        HttpRequestWithBody request = Unirest.post("https://isv.aliaddo.net/api/v1/public/documents/invoice/habilitation/4bf6673a-7a71-496e-8cfd-f7246067e4ca");

        // Adicionar cabeceras de autenticación con token Bearer generado  en el panel izquierdo
        request.header("x-api-key", "{{x-api-key}}");

        // Tipo de requerimiento formato json
        request.header("content-type", "application/json");
        request.header("cache-control", "no-cache");
        request.header("accept", "application/json");

        // Añadir el objeto de factura
        request.body(isvInvoice).asJson()
                // Manejar respuesta o error si hay alguno
                .ifSuccess(response -> System.out.println("Response: " + "status -> " + response.getStatus() + " Body -> " + response.getBody() ))
                .ifFailure(response -> {
                    System.out.println("Oh No! Status " + response.getStatus());
                    response.getParsingError().ifPresent(e -> {
                        System.out.println("Parsing Exception: " + e);
                        System.out.println("Original body: " + e.getOriginalBody());
                    });
                });
    }
}
<?php
// Asegúrese de contar con la librería cURL

// Inicializar la petición
$curl = curl_init();

// Agregando objeto factura con resolución ejemplo
$invoice = array(
    'code' => '01',
    'format' => 'Estandar',
    'emailSender' => '',
    'consecutive' => 990004337,
    'externalNumber' => '54554',
    'currencyCode' => 'COP',
    'currencyRate' => 0,
    'date' => '2020-1-22',
    'dateDue' => '2020-1-29',
    'dateStart' => '2020-1-22',
    'dateEnd' => '2020-1-29',
    'typeOfOperation' => '10',
    'dueDiligence' => '',
    'incoterms' => '',
    'terms' => '',
    'remark' => '',
    'observation' => '',
    'termDay' => 0,
    'paymentMeanCode' => '48',
    'branch' => array(
        'name' => '',
        'address' => '',
        'phone' => '',
        'countryCode' => '',
        'countryName' => '',
        'departmentCode' => '',
        'departmentName' => '',
        'cityCode' => '',
        'cityName' => ''
    ),
    'resolution' => array(
        'resolutionKey' => 'fc8eac422eba16e22ffd8c6f94b3f40a6e38162c',
        'resolutionPrefix' => 'SETP',
        'resolutionNumber' => 18760000001,
        'resolutionRangeInitial' => 990000000,
        'resolutionRangeFinal' => 995000000,
        'resolutionValidFrom' => '2019-01-19',
        'resolutionValidUntil' => '2030-01-19'
    ),
    'customer' => array(
        'companyName' => 'Customer',
        'personType' => '1',
        'regimeType' => '04',
        'firstName' => 'Customer',
        'lastName' => 'Customer',
        'identification' => '000000001',
        'digitCheck' => '8',
        'identificationTypeCode' => '13',
        'email' => '',
        'phone' => '0000001',
        'merchantRegistration' => '',
	'responsibleFor' => 'ZZ',
        'responsibilities' => 'R-99-PN',
        'economicActivities' => '2817;3092',
        'billingAddress' => 'KR con Calle',
        'billingCountryName' => 'Colombia',
        'billingCountryCode' => 'CO',
        'billingRegionName' => 'Cundinamarca',
        'billingRegionCode' => '25',
        'billingCityName' => 'Chipaque',
        'billingCityCode' => '25178',
        'billingPostalCode' => '',
        'billingNeighborhood' => '',
        'billingPhone' => '',
        'billingContactName' => '',
        'shippingAddress' => '',
        'shippingCountryName' => '',
        'shippingCountryCode' => '',
        'shippingRegionName' => '',
        'shippingRegionCode' => '',
        'shippingCityName' => '',
        'shippingCityCode' => '',
        'shippingPostalCode' => '',
        'shippingNeighborhood' => '',
        'shippingPhone' => '',
        'shippingContactName' => ''
    ),
    'invoiceDetails' => array(
        array(
            'standardType' => '',
            'standardCode' => '',
            'itemCode' => '0001',
            'itemName' => 'Item',
            'itemModel' => '',
            'description' => 'Item prueba',
            'brandName' => '',
            'itemCodeSupplier' => '',
            'isPresent' => false,
            'isRemmitance' => false,
            'remmitanceNumber' => "",
            'remmitanceConsecutive' => "",
            'remmitanceValue' => 0,
            'remmitanceQuantityValue' => 0,
            'remmitanceMeasurementUnit' => "",
            'unitMeasurementCode' => '',
            'unitMeasurementName' => '',
            'price' => 25,
            'quantity' => 2,
            'discounts' => array(
                array(
                    'name' => '',
                    'type' => 'V',
                    'rate' => 1,
                    'amount' => 1
                )
            ),
            'charges' => array(
                array(
                    'name' => '',
                    'type' => 'V',
                    'rate' => 10,
                    'amount' => 10
                )
            ),
            'taxes' => array(
                array(
                    'name' => 'Iva',
                    'code' => '01',
                    'type' => 'P',
                    'rate' => 19,
                    'amount' => 6.46
                )
            ),
            'withholdings' => array(
                array(
                    'name' => 'ReteFuente',
                    'code' => '06',
                    'type' => 'P',
                    'rate' => 10,
                    'amount' => 3.4,
                )
            ),
            'isvMandante' => array(
                'name' => 'Mandante',
                'identification' => '000001',
                'digitCheck' => '8',
                'identificationTypeCode' => '13'
            )
        )
    ),
    'totals' => array(
        'amount' => 68,
        'prepaymentAmount' => 0
    ),
    'discounts' => array(
        array(
            'name' => '',
            'type' => '',
            'rate' => 0,
            'amount' => 0
        )
    ),
    'charges' => array(
        array(
            'name' => '',
            'type' => '',
            'rate' => 0,
            'amount' => 0
        )
    ),
    'customFields' => array(
        array(
            'value' => '6666',
            'key' => 'invoiceId'
        )
    )
);

// Serializar la factura a JSON
$isvInvoice = json_encode($invoice);

/*
 * Realizar request con TestId ejemplo 4bf6673a-7a71-496e-8cfd-f7246067e4ca, cambie este TestId por el que
 * usted generó en la DIAN para habilitarse como facturador electrónico, si va realizar pruebas de conexión a
 * la API puede realizarlo con el que esta en este ejemplo
*/
$testId = '4bf6673a-7a71-496e-8cfd-f7246067e4ca';

/**
 * /invoice/habilitation/{testSetId}:
 * - Enviar una factura para set de pruebas, en modo habilitación
 * - Realizar request por metodo POST
 */
curl_setopt_array($curl, array(
    // Añadir parámetro {testId} a la ruta
    CURLOPT_URL => "https://isv.aliaddo.net/api/v1/public/documents/invoice/habilitation/$testId",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => $isvInvoice,
    CURLOPT_HTTPHEADER => array(
        // Adicionar cabeceras de autenticación con token Bearer generado  en el panel izquierdo
        "x-api-key: {{x-api-key}}",
        // Tipo de requerimiento formato json
        "content-type: application/json",
        "cache-control: no-cache",
        "accept: application/json"
    )
));

// Ejecutar la petición
$response = curl_exec($curl);

// Almacenar error en caso de que exista
$err = curl_error($curl);

// Terminar petición
curl_close($curl);

// Mostrar respuesta o error si hubo alguno
if ($err) {
    echo "cURL Error #" . $err;
} else {
    echo $response;
}
?>
# Importar la librería "requests"
import requests

# /invoice/habilitation/{testSetId}:
# - Enviar una factura para set de pruebas, en modo habilitación
# - Realizar request con TestId ejemplo 4bf6673a-7a71-496e-8cfd-f7246067e4ca, cambie este TestId por el que
# usted generó en la DIAN para habilitarse como facturador electrónico, si va realizar pruebas de conexión a
#  la API puede realizarlo con el que esta en este ejemplo
url = 'https://isv.aliaddo.net/api/v1/public/documents/invoice/habilitation/4bf6673a-7a71-496e-8cfd-f7246067e4ca'

# Crear objeto factura con resolución ejemplo

isvInvoice = {
    "code": "01",
    "format": "Estandar",
    "emailSender": "",
    "consecutive": 990077341,
    "externalNumber": "54554",
    "currencyCode": "COP",
    "currencyRate": 0,
    "date": "2020-1-22",
    "dateDue": "2020-1-25",
    "dateStart": "2020-1-22",
    "dateEnd": "2020-1-25",
    "typeOfOperation": "01",
    "dueDiligence": "",
    "incoterms": "01",
    "terms": "",
    "remark": "",
    "observation": "",
    "termDay": 0,
    "paymentMeanCode": "48",
    "branch": {
      "name": "",
      "address": "",
      "phone": "",
      "countryCode": "",
      "countryName": "",
      "departmentCode": "",
      "departmentName": "",
      "cityCode": "",
      "cityName": ""
    },
    "resolution": {
        "resolutionKey": "fc8eac422eba16e22ffd8c6f94b3f40a6e38162c",
        "resolutionPrefix": "SETP",
        "resolutionNumber": 18760000001,
        "resolutionRangeInitial": 990000000,
        "resolutionRangeFinal": 995000000,
        "resolutionValidFrom": "2019-01-19",
        "resolutionValidUntil": "2030-01-19"
    },
    "customer": {
        "companyName": "Customer",
        "personType": "1",
        "regimeType": "04",
        "firstName": "Customer",
        "lastName": "Customer",
        "identification": "000000001",
        "digitCheck": "8",
        "identificationTypeCode": "13",
        "email": "",
        "phone": "0000001",
        "merchantRegistration": "",
        "responsibleFor": "ZZ",
        "responsibilities": "R-99-PN",
        "economicActivities": "2817;3092",
        "billingAddress": "KR con Calle",
        "billingCountryName": "Colombia",
        "billingCountryCode": "CO",
        "billingRegionName": "Cundinamarca",
        "billingRegionCode": "25",
        "billingCityName": "Chipaque",
        "billingCityCode": "25178",
        "billingPostalCode": "",
        "billingNeighborhood": "",
        "billingPhone": "",
        "billingContact": "",
        "shippingAddress": "",
        "shippingCountryName": "",
        "shippingCountryCode": "",
        "shippingRegionName": "",
        "shippingRegionCode": "",
        "shippingCityName": "",
        "shippingCityCode": "",
        "shippingPostalCode": "",
        "shippingNeighborhood": "",
        "shippingPhone": "",
        "shippingContactName": ""
    },
    "invoiceDetails": [{
        "standardType": "",
        "standardCode": "",
        "itemCode": "0001",
        "itemName": "Item",
        "itemModel": "",
        "description": "Item prueba",
        "brandName": "",
        "itemCodeSupplier": "",
        "isPresent": False,
        "isPresent": False,
        "isRemmitance": False,
        "remmitanceNumber": "",
        "remmitanceConsecutive": "",
        "remmitanceValue": 0,
        "remmitanceQuantityValue": 0,
        "remmitanceMeasurementUnit": "",
        "unitMeasurementCode": "",
        "unitMeasurementName": "",
        "price": 25,
        "quantity": 2,
        "discounts": [{
            "name": "",
            "type": "V",
            "rate": 1,
            "amount": 1
        }],
        "charges": [{
            "name": "",
            "type": "V",
            "rate": 10,
            "amount": 10
        }],
        "taxes": [{
            "name": "Iva",
            "code": "01",
            "type": "P",
            "rate": 19,
            "amount": 6.46
        }],
        "withholdings": [{
            "name": "ReteFuente",
            "code": "06",
            "type": "P",
            "rate": 10,
            "amount": 3.4
        }],
        "isvMandante": {
            "name": "MAndante",
            "identification": "00000000001",
            "digitCheck": "8",
            "identificationTypeCode": "13"
        }
    }],
    "totals": {
        "amount": 68,
        "prepaymentAmount": 0
    },
    "discounts": [{
        "name": "",
        "type": "",
        "rate": 0,
        "amount": 0
    }],
    "charges": [{
        "name": "",
        "type": "V",
        "rate": 10,
        "amount": 10
    }],
    "customFields": [
        {
            "value": "666",
            "key": "invoiceId"
        }
    ]
}

# Tipo de requerimiento formato json
headers = {
    "content-type": "application/json",
    "cache-control": "no-cache",
    "accept": "application/json",
    # Adicionar cabeceras de autenticación con token Bearer generado  en el panel izquierdo
    "x-api-key": "{{x-api-key}}"
}

# - Realizar request por metodo POST
request = requests.post(url, json=isvInvoice, headers=headers)

# Mostrar respuesta de la petición
print(request.text)
print(request.status_code)
## Requerir gemas "rest-client" y "json"
require 'rest-client'
require 'json'

# /invoice/habilitation/{testSetId}:
# - Enviar una factura para set de pruebas, en modo habilitación
# - Realizar request con TestId ejemplo 4bf6673a-7a71-496e-8cfd-f7246067e4ca, cambie este TestId por el que
# usted generó en la DIAN para habilitarse como facturador electrónico, si va realizar pruebas de conexión a
#  la API puede realizarlo con el que está en este ejemplo
url = "https://isv.aliaddo.net/api/v1/public/documents/invoice/habilitation/4bf6673a-7a71-496e-8cfd-f7246067e4ca"

# Tipo de requerimiento formato json
headers = {
    "content-type": "application/json",
    "cache-control": "no-cache",
    "accept": "application/json",
    # Adicionar cabeceras de autenticación con token Bearer generado  en el panel izquierdo
    "x-api-key": "{{x-api-key}}"
}

# Crear objeto factura con resolución ejemplo
isvInvoice = {
    "code": "01",
    "format": "Estandar",
    "emailSender": "",
    "consecutive": 990077342,
    "externalNumber": "54554",
    "currencyCode": "COP",
    "currencyRate": 0,
    "date": "2020-1-22",
    "dateDue": "2020-1-25",
    "dateStart": "2020-1-22",
    "dateEnd": "2020-1-25",
    "typeOfOperation": "01",
    "dueDiligence": "",
    "incoterms": "01",
    "terms": "",
    "remark": "",
    "observation": "",
    "termDay": 0,
    "paymentMeanCode": "48",
    "branch": {
        "name": "",
        "address": "",
        "phone": "",
        "countryCode": "",
        "countryName": "",
        "departmentCode": "",
        "departmentName": "",
        "cityCode": "",
        "cityName": ""
    },
    "resolution": {
        "resolutionKey": "fc8eac422eba16e22ffd8c6f94b3f40a6e38162c",
        "resolutionPrefix": "SETP",
        "resolutionNumber": 18760000001,
        "resolutionRangeInitial": 990000000,
        "resolutionRangeFinal": 995000000,
        "resolutionValidFrom": "2019-01-19",
        "resolutionValidUntil": "2030-01-19"
    },
    "customer": {
        "companyName": "Customer",
        "personType": "1",
        "regimeType": "04",
        "firstName": "Customer",
        "lastName": "Customer",
        "identification": "000000001",
        "digitCheck": "8",
        "identificationTypeCode": "13",
        "email": "",
        "phone": "0000001",
        "merchantRegistration": "",
        "responsibleFor": "ZZ",
        "responsibilities": "R-99-PN",
        "economicActivities": "2817;3092",
        "billingAddress": "KR con Calle",
        "billingCountryName": "Colombia",
        "billingCountryCode": "CO",
        "billingRegionName": "Cundinamarca",
        "billingRegionCode": "25",
        "billingCityName": "Chipaque",
        "billingCityCode": "25178",
        "billingPostalCode": "",
        "billingNeighborhood": "",
        "billingPhone": "",
        "billingContact": "",
        "shippingAddress": "",
        "shippingCountryName": "",
        "shippingCountryCode": "",
        "shippingRegionName": "",
        "shippingRegionCode": "",
        "shippingCityName": "",
        "shippingCityCode": "",
        "shippingPostalCode": "",
        "shippingNeighborhood": "",
        "shippingPhone": "",
        "shippingContactName": ""
    },
    "invoiceDetails": [{
         "standardType": "",
         "standardCode": "",
         "itemCode": "0001",
         "itemName": "Item",
         "itemModel": "",
         "description": "Item prueba",
         "brandName": "",
         "itemCodeSupplier": "",
         "isPresent": false,
         "isPresent": false,
         "isRemmitance": false,
         "remmitanceNumber": "",
         "remmitanceConsecutive": "",
         "remmitanceValue": 0,
         "remmitanceQuantityValue": 0,
         "remmitanceMeasurementUnit": "",
         "unitMeasurementCode": "",
         "unitMeasurementName": "",
         "price": 25,
         "quantity": 2,
         "discounts": [{
             "name": "",
             "type": "V",
             "rate": 1,
             "amount": 1
         }],
         "charges": [{
             "name": "",
             "type": "V",
             "rate": 10,
             "amount": 10
         }],
         "taxes": [{
             "name": "Iva",
             "code": "01",
             "type": "P",
             "rate": 19,
             "amount": 6.46
         }],
         "withholdings": [{
              "name": "ReteFuente",
              "code": "06",
              "type": "P",
              "rate": 10,
              "amount": 3.4
          }],
         "isvMandante": {
             "name": "MAndante",
             "identification": "00000000001",
             "digitCheck": "8",
             "identificationTypeCode": "13"
         }
     }],
    "totals": {
        "amount": 68,
        "prepaymentAmount": 0
    },
    "discounts": [{
        "name": "",
        "type": "",
        "rate": 0,
        "amount": 0
    }],
    "charges": [{
        "name": "",
        "type": "V",
        "rate": 10,
        "amount": 10
    }],
    "customFields": [
        {
            "value": "666",
            "key": "invoiceId"
        }
    ]
}

# Crear petición con método POST
begin
  request = RestClient.post(url, isvInvoice.to_json, headers)
# Manejar error si hay alguno
rescue RestClient::ExceptionWithResponse => e
  puts e.response
end
# Imprimir respuesta
puts request
AnteriorFacturasSiguienteNotas débito

Última actualización hace 1 día

¿Te fue útil?