Sign in to participate
Be Kind, Be Helpful
Ask a question, answer a question, and get to know the fine people in the Harvest community.
Invoicing API - PDF generation
I would like to automate and enhance the process of sending out invoices. I would like to have my standalone app preview the invoices for approval, then send them out with return receipt and track them. From what I gather with the API, I can get what I need from Harvest, but it is not clear if I can have it deliver me a PDF.
Alternately, I could create the invoice through the API, then “screen scrape” to get the link to the invoice and download it.
Does anyone know a way to get the generated invoice PDF out of Harvest via the API?
If you know the invoice_id (from an API sense, not the Harvest user interface sense), starting a PDF download should be pretty simple. The URL format is clear:
somesubdomain.harvestapp.com/invoices/#{invoice_id}.pdf
This URL is not guaranteed to stick around in quite the way that our documented API would be, but for the time being it should work.
Just to note on this, for anyone else who might hit this issue.
If you’re getting a HTTP 302 response, make sure you’re including the header ‘Accept: application/xml’ in the request (as you do with other parts of the API).
Yes, you might be expecting a PDF; but not including the ‘Accept’ header – or using ‘Accept: application/pdf’ (which would be a sensible guess) will both seem to result in a 302 response.
Specifying ‘Accept: application/xml’ results in a HTTP 200 response (and the PDF data; it’s not XML – it can be written straight to a file).