Skip to main content

Sending Resources & Data in JSON Instructions

· 2 min read
James A. Brannan
Developer Evangelist

The DynamicPDF API pdf endpoint now accepts payloads where the payload is raw/json rather than multipart/formdata. This change allows submitting a request purely as a JSON document.

The pdf endpoint now accepts raw/json as a request's payload. This is especially useful when using a third-party library such as SalesForce's HttpRequest class.

The DynamicPDF pdf endpoint accepts JSON as the message body for HTTP Post requests. Resources embedded in the JSON document are encoded as either base64 data or strings properly encoded for embedding in a JSON document.

info

For complete details, and numerous examples, refer to the pdf(JSON) endpoint documentation.

For example, the following illustrates sending an HTTP POST request where the JSON document is sent as a JSON string.

POST /v1.0/pdf HTTP/1.1
Host: api-euw.dpdf.io
Authorization: Bearer DP--api-key--
Content-Length: 11476

{
"author": "Alex Smith",
"inputs": [
{
"type": "pdf",
"resourceName": "DocumentA.pdf",
"startPage": 1,
"pageCount": 1
},
{
"type": "pdf",
"resourceName": "DocumentB.pdf"
}
],
"resources": [
{
"name" : "DocumentA.pdf",
"data" : "--base64 encoded data--"
},
{
"name" : "DocumentB.pdf",
"data" : "--base64 encoded data--"
}
]
}

Now when using the pdf endpoint you can send PDF, Word, Excel, images, and other resources embedded directly in the JSON request.

For complete details, and numerous examples, refer to the pdf(JSON) endpoint documentation.