CODIGO JAVA REST API

Autenticacion
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
 
import java.io.IOException;
 
public class Main {
    public static void main(String[] args) throws IOException {
        String url = "https://testemision.thefactoryhka.com.do/api/Autenticacion";
        String json = "{\"usuario\": \"130960054_int\",\"clave\": \"130960054\",\"rnc\": \"130960054\"}";
 
        HttpClient httpClient = HttpClientBuilder.create().build();
        HttpPost request = new HttpPost(url);
        StringEntity params = new StringEntity(json);
        request.addHeader("content-type", "application/json");
        request.setEntity(params);
 
        HttpResponse response = httpClient.execute(request);
        System.out.println(response);
    }
}
EstatusDocumento
import requests
import json
 
respjson={"Codigo": 1,"Mensaje": " ", "Procesado": False} #Creamos un objeto respuesta en json
 
j={"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjEzMDk2MDA1NCIsImVtYWlsIjoiMTMwOTYwMDU0X2ludCIsIm5iZiI6MTY0ODU2NjAxNCwiZXhwIjoxNjQ4NjE0NDM0LCJpYXQiOjE2NDg1NjYwMTR9.KCaf5qqQ2A_8-nUQCV-9ttwhsRwnwVL_MiHfDvfe5A4","documento": "E310000003452","rnc": "130960054"}  #convertimos el string a json
response = requests.post("https://testemision.thefactoryhka.com.do/api/EstatusDocumento",json=j) #enviamos el post a la url con los datos 
 
print("\r\n"+"***********************************************************************************")
print(response.json()) #imporimimos el resultado en json
print("\r\n"+"***********************************************************************************")
respjson=json.dumps(response.json())
print(respjson.capitalize()) #imporimimos el resultado en json en minusculas
Enviar
import requests
import json
 
respjson={"xmlBase64": "","procesado":False, "codigo": 1,"mensaje":"" } #Creamos un objeto respuesta en json
 
#Creamos una factura json
 
j={
  "Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjEzMDk2MDA1NCIsImVtYWlsIjoiMTMwOTYwMDU0X2ludCIsIm5iZiI6MTY0ODU2NjAxNCwiZXhwIjoxNjQ4NjE0NDM0LCJpYXQiOjE2NDg1NjYwMTR9.KCaf5qqQ2A_8-nUQCV-9ttwhsRwnwVL_MiHfDvfe5A4",
 "documentoElectronico": {
		"encabezado": {
			"identificacionDocumento": {
				"tipoDocumento": "31",
				"ncf": "E310000003453",
				"fechaVencimientoSecuencia": "31-12-2022",
				"indicadorEnvioDiferido": "1",
				"indicadorMontoGravado": "1",
				"indicadorNotaCredito": None,
				"tipoIngresos": "01",
				"tipoPago": "1",
				"fechaLimitePago": None,
				"terminoPago": None,
				"tablaFormasPago": [
					{
						"forma": "1",
						"monto": "400000.00"
					}
				],
				"tipoCuentaPago": None,
				"numeroCuentaPago": None,
				"bancoPago": None,
				"fechaDesde": None,
				"fechaHasta": None
			},
			"emisor": {
				"rnc": "130960054",
				"razonSocial": "TheFactoryHKA C.A",
				"nombreComercial": "TheFactoryHKA C.A",
				"sucursal": "Sucursal",
				"direccion": "Av. Los Beisbolistas esq. Ant. Carretera Duarte, Plaza Shantell, Locales B6 y B7",
				"municipio": "320100",
				"provincia": "320000",
				"tablaTelefono": [
					"809-472-7676",
					"809-491-1918"
				],
				"correo": "[email protected]",
				"webSite": "www.thefactoryhka.com/rd",
				"actividadEconomica": None,
				"codigoVendedor": "GENETRIX0000000000000000001",
				"numeroFacturaInterna": "000000000000212",
				"numeroPedidoInterno": "000000000000212",
				"zonaVenta": "NORTE",
				"rutaVenta": None,
				"informacionAdicional": None,
				"fechaEmision": "29-03-2022"
			},
			"comprador": {
				"rnc": "101072148",
				"identificacionExtranjero": None,
				"razonSocial": "DISTRIBUIDORA DE COSMETICOS SAS (DISCOSA)",
				"contacto": "DISCOSA",
				"correo": "[email protected]",
				"direccion": "RD dirección",
				"municipio": "010100",
				"provincia": "010000",
				"pais": "Pais",
				"fechaEntrega": "26-12-2021",
                "FechaOrdenCompra":"10-11-2018",
				"contactoEntrega": None,
				"direccionEntrega": None,
				"telefonoAdicional": None,
				"fechaOrden": "24-12-2021",
				"numeroOrden": "4500352238",
				"codigoInterno": "10633440",
				"responsablePago": None,
				"informacionAdicional": None
			},
			"informacionesAdicionales": {
				"fechaEmbarque": None,
				"numeroEmbarque": None,
				"numeroContenedor": "8019289",
				"numeroReferencia": "1447",
				"pesoBruto": None,
				"pesoNeto": None,
				"unidadPesoBruto": None,
				"unidadPesoNeto": None,
				"cantidadBulto": None,
				"unidadBulto": None,
				"volumenBulto": None,
				"unidadVolumen": None,
				"nombrePuertoEmbarque": None,
				"condicionesEntrega": None,
				"totalFob": None,
				"seguro": None,
				"flete": None,
				"otrosGastos": None,
				"totalCif": None,
				"regimenAduanero": None,
				"nombrePuertoSalida": None,
				"nombrePuertoDesembarque": None
			},
			"transporte": None,
			"totales": {
				"montoGravadoTotal": None,
				"montoGravadoI1": None,
				"montoGravadoI2": None,
				"montoGravadoI3": None,
				"montoExento": "400000.00",
				"itbiS1": None,
				"itbiS2": None,
				"itbiS3": None,
				"totalITBIS": None,
				"totalITBIS1": None,
				"totalITBIS2": None,
				"totalITBIS3": None,
				"montoImpuestoAdicional": None,
				"impuestosAdicionales": None,
				"montoTotal": "400000.00",
				"montoNoFacturable": None,
				"montoPeriodo": None,
				"saldoAnterior": None,
				"montoAvancePago": None,
				"valorPagar": None,
				"totalITBISRetenido": None,
				"totalISRRetencion": None,
				"totalITBISPercepcion": None,
				"totalISRPercepcion": None
 
			},
			"otraMoneda": None
		},
		"detallesItems": [
			{
				"numeroLinea": "1",
				"tablaCodigos": None,
				"indicadorFacturacion": "4",
				"retencion": None,
				"nombre": "ASW DTU",
				"indicadorBienoServicio": "1",
				"descripcion": None,
				"cantidad": "10000.00",
				"unidadMedida": "47",
				"cantidadReferencia": None,
				"unidadReferencia": None,
				"tablaSubcantidad": None,
				"gradosAlcohol": None,
				"precioUnitarioReferencia": None,
				"fechaElaboracion": None,
				"fechaVencimiento": None,
				"mineria": None,
				"precioUnitario": "40.00",
				"descuentoMonto": None,
				"tablaSubDescuento": None,
				"recargoMonto": None,
				"tablaSubRecargo": None,
				"tablaImpuestoAdicional": None,
				"otraMonedaDetalle": None,
				"monto": "400000.00"
			}
		],
		"subtotales": None,
		"descuentosORecargos": None,
		"informacionReferencia": None
	}
}
 
 
 #convertimos el string a json y capturamos la respuesta
response = requests.post("https://testemision.thefactoryhka.com.do/api/Enviar",json=j) #enviamos el post a la url con los datos 
 
 
 
print("\r\n"+"***********************************************************************************")
print(response.json()) #Imprimimos el resultado en json
print("\r\n"+"***********************************************************************************")
respjson=json.dumps(response.json())
print(respjson.capitalize()) #imporimimos el resultado en json en minusculas