Content negotiation


Sending requests

When sending requests to the PdfBroker api you can of course send your data as JSON which is the most common way to use a REST api. But when using our service where you send binary data, like images that is referenced in your XSL-FO documents you have the option to send the request as "multipart/form-data". That is the same format your browser uses when uploading a file in a form.

The Content-Type header

To tell our api which format you are using you need to set the Content-Type header of your request as either "application/json" or "multipart/form-data". The benefit of using the latter format is the size of your request. When sending images in JSON format the api expects the binary data to be encoded as a Base64 string. Encoding your images as Base64 causes an increase of the request size by approximatly 33% compared to the original format of the file. 

The response

You can also decide how you want to recieve your generated PDF files. You can either recieve your generated file as JSON, then it will be Base64 encoded, and you need to decode the response before reading the response with a PDF reader. The alternative is the receive the generated PDF file directly.

The Accept header

To tell the PdfBroker api how you wish to receive your PDF file is by setting the Accept header in your request. To receive data as JSON you set the Accept header to "application/json" and to receive a binary file you set the Accept header to "application/pdf".