Puedes generar un PDF con la información de un documento de venta
En esta sección aprenderás cómo utilizar la API para obtener un archivo PDF asociado a un documento de venta.
Para obtener un archivo PDF utilizaremos el verbo http GET.
API endpoint exclusivo para partners que trabajen con factura electronica.
Formato de respuesta | JSON |
---|---|
¿Requiere autenticación? | SI |
¿Requiere token? | SI |
¿Requiere Partner key? | NO |
Nombre | Descripción | Tipo del parámetro | Tipo del dato |
---|---|---|---|
rut | Rut de la empresa | Path | String |
numeroSerie | Número de serie del sistema, este valor se obtiene desde el resultado de la autenticación API | Path | Boolean |
numFolio | Folio del documeto de compra | Path | Integer |
tipoDocumento |
Abreviación del tipo de documentos FAC-EL: Factura electrónica FAC-EE:Factura exenta electrónica N/D-EL: Nota débito electrónica N/C-EL:Nota de crédito electrónica BOL-EL: Boleta electrónica BOL-EE: Boleta exenta electrónica para los valores con / remplazar por %2F |
Path | String |
En este apartado se entrega información importante que debes tener en consideración.
curl --location --request GET 'https://api.nubox.com/Nubox.API.cert/factura/documento/15478788-7/1/1/FAC-EL/pdf' \ --header 'token: 898e879d-ccba-40c4-898c-5d4a97f8ed9c' \ --header 'Cookie: .Stackify.Rum=f0af7579-7902-4bd2-b8e9-2fd72872bd71'
var settings = { "url": "https://api.nubox.com/Nubox.API/factura/documento/15478788-7/1/1/FAC-EL/pdf", "method": "GET", "timeout": 0, "headers": { "token": "898e879d-ccba-40c4-898c-5d4a97f8ed9c", "Cookie": ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da" }, }; $.ajax(settings).done(function (response) { console.log(response); });
var myHeaders = new Headers(); myHeaders.append("token", "898e879d-ccba-40c4-898c-5d4a97f8ed9c"); myHeaders.append("Cookie", ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da"); var urlencoded = new URLSearchParams(); var requestOptions = { method: 'GET', headers: myHeaders, body: urlencoded, redirect: 'follow' }; fetch("https://api.nubox.com/Nubox.API/factura/documento/15478788-7/1/1/FAC-EL/pdf", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
var data = ""; var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function() { if(this.readyState === 4) { console.log(this.responseText); } }); xhr.open("GET", "https://api.nubox.com/Nubox.API/factura/documento/15478788-7/1/1/FAC-EL/pdf"); xhr.setRequestHeader("token", "898e879d-ccba-40c4-898c-5d4a97f8ed9c"); xhr.setRequestHeader("Cookie", ".Stackify.Rum=4c648f24-1d4f-4817-a602-57005e5e24da"); xhr.send(data);
var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.nubox.com/Nubox.API.cert/factura/documento/15478788-7/1/1/FAC-EL/pdf', 'headers': { 'token': '898e879d-ccba-40c4-898c-5d4a97f8ed9c', 'Cookie': '.Stackify.Rum=f0af7579-7902-4bd2-b8e9-2fd72872bd71' } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); });
var client = new RestClient("https://api.nubox.com/Nubox.API.cert/factura/documento/15478788-7/1/1/FAC-EL/pdf"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("token", "898e879d-ccba-40c4-898c-5d4a97f8ed9c"); request.AddHeader("Cookie", ".Stackify.Rum=f0af7579-7902-4bd2-b8e9-2fd72872bd71"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.nubox.com/Nubox.API.cert/factura/documento/15478788-7/1/1/FAC-EL/pdf", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "token: 898e879d-ccba-40c4-898c-5d4a97f8ed9c", "Cookie: .Stackify.Rum=f0af7579-7902-4bd2-b8e9-2fd72872bd71" ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
require "uri" require "net/http" url = URI("https://api.nubox.com/Nubox.API.cert/factura/documento/15478788-7/1/1/FAC-EL/pdf") https = Net::HTTP.new(url.host, url.port); https.use_ssl = true request = Net::HTTP::Get.new(url) request["token"] = "898e879d-ccba-40c4-898c-5d4a97f8ed9c" request["Cookie"] = ".Stackify.Rum=f0af7579-7902-4bd2-b8e9-2fd72872bd71" response = https.request(request) puts response.read_body
package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.nubox.com/Nubox.API/factura/documento/15478788-7/1/1/FAC-EL/pdf" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) } req.Header.Add("token", "898e879d-ccba-40c4-898c-5d4a97f8ed9c") req.Header.Add("Cookie", ".Stackify.Rum=f0af7579-7902-4bd2-b8e9-2fd72872bd71") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) }
OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.nubox.com/Nubox.API.cert/factura/documento/15478788-7/1/1/FAC-EL/pdf") .method("GET", null) .addHeader("token", "898e879d-ccba-40c4-898c-5d4a97f8ed9c") .addHeader("Cookie", ".Stackify.Rum=f0af7579-7902-4bd2-b8e9-2fd72872bd71") .build(); Response response = client.newCall(request).execute();
Archivo PDF
Nombre | Valor |
---|---|
Date | Mon, 22 Jun 2020 04:41:48 GMT |
Content-Type | application/pdf |
Content-Length | 14632 |
content-disposition | attachment; filename=1.pdf |