Test API With Postman.
DynamicPDF API's endpoints are easily tested using Postman.
Use The DynamicPDF API's Postman collection to test using the six endpoints provided by API. To make testing easier we provide a Postman Collection and Environment you can import.
Here we provide a tutorial on using the collection and environment.
You have probably heard of Postman if you have developed or used APIs. Postman is an exceptional tool for testing APIs and ensuring everything is functioning correctly. With Postman, it's a breeze to send requests to APIs and receive responses in an easy to understand interface.
Download Postman for free at their website (Download Postman).
Refer to the Postman Learning Center for more complete documentation detailing how to use Postman.
In this tutorial we provide a Postman environment file and a collection
Download the environment and collection files and install in Postman before continuing.
Environment
The DynamicPDFCloudAPI.postman_environment.json
provides the variables used by your collection's Postman requests. Use environments to group related values together.
Refer to Managing Environments for more information on environments.
The DynamicPDF API environment contains two variables, Authorization
and API-URL
. Replace the Authorization
variable's value with your desired value from the DynamicPDF CloudAPI Portal's Apps and API Keys. Also ensure the value for API-URL
is correct.
Be certain to change the URL if using one of our endpoint zones.
Templates
DynamicPDF has six Postman templates corresponding to the six REST endpoints.
Template | Endpoint |
---|---|
image-info template | image-info |
pdf-info template | pdf-info |
pdf-text template | pdf-text |
pdf-xmp template | pdf-xmp |
dlex-layout template | dlex-layout |
pdf template |
image-info
The image-info
endpoint is a POST request that takes an Authorization
key and Content-Type
in the request header. The POST's body is binary and so Postman provides a Select File button for you to select the image file from your local system.
pdf-info
The pdf-info
endpoint is a POST request that takes an Authorization
key and Content-Type
in the request header. The POST's body is binary and so Postman provides a Select File button for you to select the PDF file from your local system.
dlex-layout
The dlex-layout
endpoint is a POST request that takes an Authorization
key and Content-Type
in the request header. The POST's body is form-data with a LayoutData
and DlexPath
form fields. The LayoutData
is a file from your local system and so Postman provides a Select File button for you to select the JSON file from your local system. The DlexPath
is a text field that takes the relative path from your CloudAPI storage space.
pdf
The pdf
endpoint is a POST request that takes an Authorization
key and Content-Type
in the request header. The POST's body is form-data with a Instructions
and one or more Resource
form fields. The Instructions
is a file from your local system and so Postman provides a Select File button for you to select the JSON file from your local system. The Resource
is also a file from your local system.
Recall that the instructions.json
specifies resources in your CloudAPI storage space.
Examples
- Open the DynamicPDF CloudAPI environment tab.
- Modify the value for the authorization key.
- Make the environment active by checking the activation link.
image-info Example
- Duplicate the image-info Template in Postman.
- Add the Get Image Information sample project from your cloud storage space.
- Copy the
dynamicpdfLogo.png
to your local filesystem.
- Use the Select File button to select the file path to
dynamicpdfLogo.png
. - Click the Send button to call the endpoint and the endpoint returns the image's information.
- Duplicate the pdf-text template and select any PDF from your local file system.
- Send the request and it returns the PDF's text.
- Duplicate the pdf-xmp template.
- Add the Get XMP Metadata sample project to your cloud storage space and download
fw4.pdf
to your local file system. - Submit the PDF to the endpoint and it return the PDF's XMP metadata.
Be certain to use a PDF document with XMP metadata. Download fw4.pdf
from the Get XMP Metadata sample project if you require a sample PDF.
dlex-layout Example
- Add the dlex-layout Endpoint sample to your cloud storage.
- Download
SimpleReportWithCoverPage.json
to your local file system.
- Duplicate the dlex-layout template in Postman.
- Add the downloaded JSON file as your
LayoutData
. - Set the
DlexPath
field's value as the relative path in cloud storage to the DLEX file. - Click Send and the endpoint generates and returns the PDF.
pdf Example
- Add the Merge PDFs sample project to your cloud storage.
- Download
instructions.json
,DocumentA.pdf
, andDocumentB.pdf
to your local file storage. - Open
instructions.json
in a text editor.
The instructions document has processing information for creating the merged PDF. The input types are the three PDF documents to merge. The first two are local resources, and so are not provided a relative path. Instead, when we call the endpoint we pass the content of those two files in the request as binary. The third resource is on the cloud, and so it specifies the relative path in cloud storage to the PDF.
{
"author": "Alex Smith",
"inputs": [
{
"type": "pdf",
"resourceName": "DocumentA.pdf",
"startPage": 1,
"pageCount": 1
},
{
"type": "pdf",
"resourceName": "DocumentB.pdf"
},
{
"type": "pdf",
"resourceName": "samples/merge-pdfs-pdf-endpoint/DocumentC.pdf"
}
]
}
- Add
instructions.json
to the Instructions form field. - Create a new
Resource
form field of type file. - Add
DocumentA.pdf
to the first Resource andDocumentB.pdf
to the second. - Send the request to the endpoint and it returns the merged PDF.