Enviar factura en modo pruebas

Modo pruebas

Enviar factura

POST https://isv.aliaddo.net/api/v1/public/documents/invoice/test

Enviar una factura a la DIAN en modo pruebas.

Path Parameters

Name
Type
Description

version

string

Versión de la API

Headers

Name
Type
Description

x-api-key

string

Token generado previamente para autenticarse

Request Body

Name
Type
Description

isvInvoice

string

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",
	"dueDiligence": "",
	"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
}

Código de ejemplo

using System;
using Newtonsoft.Json;
using RestSharp;

public class Program
{
    public static void Main()
    {
        /**
            - Enviar una factura a la DIAN, en modo pruebas
            - Instale RestSharp via Nuget: Install-Package RestSharp -Version 106.6.10
            - Instale Newtonsoft via Nuget: Install-Package Newtonsoft.Json
        */
        
        var request = new RestRequest("invoice/test", 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 protected]",
            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);
        }
    }
}

Última actualización

¿Te fue útil?