Factuur document downloaden

<< Klik hier om de inhoudsopgave te tonen >>

Navigatie:  API aanroepen >

Factuur document downloaden

Voor het downloaden van een factuur document in PDF of UBL formaat is het download token van de betreffende factuur nodig (zie: Factuur toevoegen of Factuur opvragen).

 

Download URL's

voor factuur in PDF formaat: https://api.stip-t.nl/getinvoicedoc/invoice.pdf?token=[token]

voor factuur in UBL formaat: https://api.stip-t.nl/getinvoicedoc/invoice.xml?token=[token]

 

Voorbeeld code (Java)

import java.io.BufferedInputStream;

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.net.HttpURLConnection;

import java.net.URL;

 

public class example

{

 public static void main( String[] args ) throws IOException

 {

   // download PDF file (or UBL file)

   String token = "[token]";

   String outputFileName = "c:\\temp\\myPdf.pdf";

   String ext = "pdf"; // i.e. pdf or xml

 

   //Create connection

   URL url = new URL("https://api.stip-t.nl/getinvoicedoc/invoice." + ext + "?token=" + token);

   HttpURLConnection connection = (HttpURLConnection)url.openConnection();

   connection.setRequestMethod("GET");

   connection.setDoOutput(true);

 

   //Save PDF (or XML) to outputFileName

   BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());

   BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(outputFileName)));

   int inByte;

   while ((inByte = bis.read()) != -1)

     bos.write(inByte);

   bis.close();

   bos.close();

 }

}