Search code examples
restconvertapi

ConvertAPI giving 4000 Parameter validation error - file must be greater than 0, but I'm sending a large file


I'm trying to post to ConvertAPI's pdf/to/jpg endpoint, and am getting the following error:

 {"Code":4000,"Message":"Parameter validation error.","InvalidParameters":{"File":["File size must be greater than 0 bytes.","The File field is required."]}}

I am sending the file data, which I receive as a blob and base64encode, and can see it in my debugs.

My request, with the base64 string truncated:

{"FileName":"censusImage.jpg","File":"JVBERiiI2EF6eSAYCGS41Z3jqiktLHUquM3G/BK+sC/DOHAAFpQ12ufvOCXs5ZfWOcuK8/VnqGWp+2saDWXFZ11YNVDlyJWrZTDCtArsLekqs6X0U/GCg==","ColorSpace":"default","ImageQuality":75,"ImageAntialiasing":8,"ImageHeight":500,"ScaleProportions":true,"ImageResolution":200,"PageRange":1,"StoreFile":false,"Timeout":900}

Does anyone have any idea what I'm getting wrong?


Solution

  • The request JSON payload is not correct. You can find the correct one at https://www.convertapi.com/pdf-to-jpg

    {
        "Parameters": [
            {
                "Name": "File",
                "FileValue": {
                    "Name": "my_file.pdf",
                    "Data": "<Base64 encoded file content>"
                }
            }
        ]
    }
    

    Also I suggest to use multipart for requests and not JSON.