About GetDocumentPages
This API retrieves the number of pages in an attachment. The attachment can of different entity types, such as bill or invoice. The API response also includes a link to download the text or image document.
Example
Request
<API_URL_EndPoint>/GetDocumentPages.json
data={
"id" : "00n01TUPMWVLJHJUR1mg"
}
Response
Bills with no attachments
{
"response_status" : 0,
"response_message" : "Success",
"response_data" : {
"documentPages" : {
"numPages" : null,
"fileUrl" : null
}
}
}
Bill with single text attachment
{
"response_status" : 0,
"response_message" : "Success",
"response_data" : {
"documentPages" : {
"numPages" : 1,
"fileUrl" : "/HtmlServlet?id=00h01CVAXWJWPFDHnejl"
}
}}
Note: To download a text attachment in the HTML format, use the GET request for https://api-sandbox.bill.com/HtmlServlet?id=<Returned_fileUrl_ID>
.
&sessionId=<Session_ID>
Example: https://api-sandbox.bill.com/HtmlServlet?id=00h01CVAXWJWPFDHnejl
&sessionId=!b3444456WZHJddffr-ddfffgh-4thgd-Ty.01
Bill with multi-page attachment (Text & PDF)
{
"response_status" : 0,
"response_message" : "Success",
"response_data" : {
"documentPages" : {
"numPages" : 7,
"fileUrl" : "/is/BillImageServlet?entityId=00n01ZRWJXVKATP1s8bb"
}
}
}
Note: To download an attachment with many pages, use the GET request for https://api-sandbox.bill.com/is/BillImageServlet?entityId=<Entity_ID>&
.
sessionId=<Session_ID>&pageNumber=<Page_Number>
If the first page of your attachment is text or if your entire attachment is a text file that has many pages, the fileUrl
value you get is similar to /HtmlServlet?id=<System_Generated_HTML_File_ID>
. When downloading this attachment, use /is/BillImageServlet?entityId=<Entity_ID>
in your GET request and set entityId
as the retrieved fileUrl
value.
In this example, you download the fifth page of a bill attachment with ID 00n01ZRWJXVKATP1s8bb: https://api-sandbox.bill.com/is/BillImageServlet?entityId=
00n01ZRWJXVKATP1s8bb&sessionId=!b3444456WZHJddffr-ddfffgh-4thgd-Ty.01
&pageNumber=5
Files are unable to be downloaded as full PDF files. Instead, all files are downloaded in PNG format.
Resources
Parameters
Field Name | Description | Required? |
---|---|---|
id | System generated ID of the Object (Bill) | Yes |