Converting Documents to PDF

Converting Documents to PDF

API Key Type Required: Publication API

Book Block Conversion

Purpose

This API begins a new conversion job for creating a book block PDF.  Before calling this API, you must upload the source documents using the file management API and retrieve the file ID.

Request Type:  POST

QUERY_STRING

  • api_key -- Your api key for the Publication API.
  • auth_token -- The auth token returned from the authenticator API.

POST Arguments

  • An XML or JSON representation of a conversion manifest, specified by the Content-Type HTTP header.

Endpoint

https://apps.lulu.com/api/create/v1/conversion?api_key=${your api key}&auth_token=${authentication token}

Response

An XML or JSON representation of a conversion status according to request's Accept header.

Errors

On errors, the HTTP response will not be 200.  The notifications structure will contain a human readable explanation of the error as well as an error code.  If the convert method returns an error, then the conversion is not begun.  You must fix the error and re-submit the conversion request.  There are 5 possible validation errors:
  • Positive integer not supplied for both width and height (if required)
  • Invalid file ID or mime type supplied
  • Output format not supplied
  • File indices are not supplied or non-sequential
  • Cumulative size of input files exceeds 2G

Book Block Conversion Status

Purpose

Because conversion is an asynchronous process, it is possible to check the status of your conversion at any time.  This allows you to keep abreast of what is happening with your files.

Request Type:  GET

QUERY_STRING

  • conversionId -- The conversion for which you are requesting information.
  • api_key -- Your api key for the Publication API.
  • auth_token -- The auth token returned from the authenticator API.

Endpoint

https://apps.lulu.com/api/create/v1/conversion/{conversionId}?api_key={your api key}&auth_token={authentication token}

Response

An XML or JSON representation of a conversion status.

For XML, set the HTTP header Accept to application/xml.  For JSON, set the Accept header to application/json.

Errors
On errors, the HTTP response will not be 200.  The notifications structure will contain a human readable explanation of the error as well as an error code.  If there is an error while converting files, the conversion will be termininated, and must be resubmited.  There are 5 possible conversion errors:
  • Input mime type cannot be handled
  • Conversion between provided input and output mime types not supported
  • Provided file is corrupt
  • Provided file is encrypted or locked
  • Conversion would result in output file exceeding 2G

2 Comments

  1. Spiro1 year ago

    Hi, hope someone can help me. I'm sending the following:

    {"outputFormat":"application/pdf","outputDimensions":{"widthInPoints":612,"heightInPoints":792},"conversionFiles":[{"uri":"fileId:4f88640ed0892d2f05fc8f19","mimeType":"application/msword","index":0}],"customField":null,"callback":null}

    But every single time I get the following notification:

    {"notifications":[{"severity":"ERROR","text":"Error deserializing request. Please check that your media type header is set to a valid MIME type.","code":1000020003}]}

    Honestly I don't know what am I doing wrong. Can anyone advice?

    Thanks

  2. Spiro1 year ago

    This was the solution to my problem (answer by Ryan Bloom): "[...]our new APIs accept both JSON and XML as input and output. We do not attempt to determine which you are sending though. To ensure that we parse your input as JSON, you must send us a 'Content-Type' header in your request. In your case, the header should be:

    Content-Type: application/json

    To ensure that you get JSON back from us, you should also include:

    Accept: application/json

    [...]"

    Hope it helps

Please sign in to post a comment.