Articles on: Documentation

Request Content Types

All content types and schemes that are supported by ConvertAPI are covered in this documentation section.

Request Content Types



HTTP Requests must be sent with one of the following content types:

- application/json
- multipart/form-data
- application/octet-stream


application/json



File data must be encoded with Base64 encoding, provided as a URL or uploaded File ID.

DOC to PDF example

[POST]
https://v2.convertapi.com/convert/doc/to/pdf?Secret=your-api-secret
{
    "Parameters": [
        {
            "Name": "File",
            "FileValue": {
                "Name": "my_file.doc",
                "Data": "--Base64 encoded file content--"
            }
        }
    ]
}


Merge PDF scheme example (multiple source files)

[POST]
https://v2.convertapi.com/convert/pdf/to/merge?Secret=your-api-secret
{
    "Parameters": [
        {
            "Name": "StoreFile",
            "Value": "true"
        },
        {
            "Name": "PdfVersion",
            "Value": "1.7"
        },
        {
            "Name": "Files",
            "FileValues": [
                {
                    "Name": "file.pdf",
                    "Data": "--Base64 encoded file content--"
                },
                {
                    "Url": "http://example.com/myfile.docx"
                },
                {
                    "Id": "0ba132ddd698aaeafcf19ec0015e10e0"
                }
            ]
        }
    ]
}



multipart/form-data



Each request parameter must be specified in a separate part. If there is an array type parameter, the index must be appended to a parameter name e.g. Files[0], Files[1], Files[2], etc.

DOC to PDF example

[POST] 
https://v2.convertapi.com/convert/doc/to/pdf?secret=your-api-secret HTTP/1.1
Content-Type: multipart/form-data; boundary=----7MA4YWxkTrZu0gW

------7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="StoreFile"

true
------7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="File"; filename="my_file.doc"
Content-Type: 

--FILE DATA--
------7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="DocumentTitle"

Test title
------7MA4YWxkTrZu0gW--



application/octet-stream



The most bandwidth-efficient way to convert a file is to pass file content as a request body. This content type could also be used for stream processing. The request header must contain the Content-Disposition: attachment; filename="my_file.doc" field with the file name and correct file extension. Conversion parameters can be set through the URL query.


Query parameters



It is possible to convert a file that is accessible by URL or uploaded File ID using only the query parameters.

DOCX to PDF example

[GET/POST]
https://v2.convertapi.com/convert/docx/to/pdf?Secret=your-api-secret&File=http://example.com/myfile.docx&StoreFile=true


If there is an array type parameter, the index must be appended to parameter name e.g. Files[0], Files[1], Files[2], etc.

Updated on: 22/02/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!