Downloading invoice documents (PDF) from REST or SOAP API
Is it possible to download the invoice PDF via the REST (preferred) or SOAP API?
In the interface I can find them here:
https://REDACTED-sb1.app.netsuite.com/app/common/media/mediaitemfolders.nl?folder=-9&whence=
If you can call a Restlet (could be the name / internalid of a file), the response could be the content of a pdf in the filecabinet , yes.
Thanks for your answer Nelliott.
We are trying to build a generic integration for multiple clients. This requires us to create a custom script for each of our clients, correct? I assume this is not possible via the default REST API? Maybe via a custom field?
To clarify, if you’re looking to create a RESTlet that returns a PDF from the filecabinet, this could be quite simple.
You would need to pass in something that identifies the file by name if you do not know the internal id of the file in the filecabinet.
The RESTlet would search for the file, load and return the content as base64 encoded content or a suitable message if the file is not found.
You could manage access via access tokens with one RESTlet serving all clients.
If Invoice pdf already existed in file cabinet then create RestLet load record and send a complete object as API response. And can save API response in .pdf format and it will work.
Thanks, I’ve got this working. However, this is not an ideal solution as the RESTLET url will be different for each client. This will take extra setup time and a need to store the RESTLET url per customer.
Would be great if there was a dedicated API route that returns the file contents when you request a specific file id.
You should be able to use one RestLet Url and just manage access tokens to allow multiple users to access it, not sure why you believe you need separate urls unless your code needs to work differently for different users?
In which case you could just add a parameter to the url which identifies the user and branch the code accordingly. (admittedly at that point the url would be different just not the base url/RestLet)
Also if you know the id of the file you can just load and return it, it’s only if you have to search for the file it adds an extra step.
We serve multiple clients independent of eachother. So every client has their own Netsuite environment.
They all need to install the RESTLET code, which leads to different urls. (The same goes for the different CLIENT_ID and CLIENT_SECRET)