Cannot open some documents uploaded via Documents POST Upload

For requests or help with our API
Post Reply
studiofellow
Posts: 12
Joined: Tue Feb 27, 2024 9:29 am
Contact:

Cannot open some documents uploaded via Documents POST Upload

Post by studiofellow » Tue Jul 08, 2025 2:33 pm

On some images uploaded via Document POST, we get this error when trying to view inside Open Dental:
File found but cannot be opened, probably because it's too big
Is there a filesize limit for the Documents POST endpoint or inside Open Dental itself?

Thanks!

SLeon
Posts: 590
Joined: Mon Mar 01, 2021 10:00 am

Re: Cannot open some documents uploaded via Documents POST Upload

Post by SLeon » Wed Jul 09, 2025 7:19 am

Good morning,

There are six different Documents POST API methods, which one are you using? Please also describe/screenshot the JSON payload in your request.

studiofellow
Posts: 12
Joined: Tue Feb 27, 2024 9:29 am
Contact:

Re: Cannot open some documents uploaded via Documents POST Upload

Post by studiofellow » Wed Jul 09, 2025 8:37 am

Thanks for the reply! On the API spec, it's called Documents POST Upload as shown in my question, it's the one that uses rawBase64. See screenshot.

The json payload looks like:

Code: Select all

{
      PatNum: patNum,
      rawBase64: base64,
      extension: '.png',
      Description: 'signed treatment plan screenshot from why/care',
}
The base64 variable above is an image in png format, converted from an image buffer to base64 using javascript. The original is usually around 5mb, but can be larger. See this dropbox link for an example.

Thanks again!
Attachments
Screenshot 2025-07-09 at 9.27.42 AM.png
Screenshot 2025-07-09 at 9.27.42 AM.png (60.85 KiB) Viewed 20 times

SLeon
Posts: 590
Joined: Mon Mar 01, 2021 10:00 am

Re: Cannot open some documents uploaded via Documents POST Upload

Post by SLeon » Wed Jul 09, 2025 10:44 am

Ah, I missed it in the thread title, thank you for clarifying this and including your JSON payload.

Users will see that error message when there is any issue converting the Base64 string into an image. For example, sending an invalid string such as "rawBase64": "apple" will ultimately produce the error message you reported. Because it is only some of your images that fail, you should check to make sure those Base64 strings are accurate. There are online tools that can convert to and from Base64 so you can easily check these.

Barring that, can you please clarify if the 5MB is the size of the base64 string you are sending or if it is the size of the final image? It sounds like you are below the threshold documented on our Implementations page.
Body
In PUT and POST requests, the JSON body can have a maximum content length of 16.8M characters.
This cap is set specifically for this Documents POST Upload endpoint, so I doubt this is the issue.

studiofellow
Posts: 12
Joined: Tue Feb 27, 2024 9:29 am
Contact:

Re: Cannot open some documents uploaded via Documents POST Upload

Post by studiofellow » Wed Jul 09, 2025 11:28 am

You bet, and thanks, hadn't seen the JSON request character limit. That and the clarification of the error message gives me more to look into!

The 5MB is the approximate size of the final image file on our web server. Our code works like this:

1. Website takes screenshot of the page, saves it to our web server
2. When the image is saved, this triggers a cloud function that loads the screenshot, converts to Base64, calls Documents POST upload
3. On success response, the original image is deleted from our web server

Unfortunately the images causing the issue were deleted from our server because we received a 201 Created response. I'm going to temporarily disable the image deletion so I can look at the images causing the issue in more detail and check the Base64 like you advised.

Thanks for your help -- I'll update the thread again if I have more questions!

studiofellow
Posts: 12
Joined: Tue Feb 27, 2024 9:29 am
Contact:

Re: Cannot open some documents uploaded via Documents POST Upload

Post by studiofellow » Wed Jul 09, 2025 12:32 pm

No questions yet, but a little more info:

I added new code to compress the images before uploading. A compressed image resulting in 1.72MB filesize translates to base64 string length of 2,408,712.

The original uncompressed file was 5.15MB, or roughly triple. Assuming that would translate to 7.5M characters in base64, even if we had an image double that original size, we'd still be well short of the 16.8M limit. Also, since we got back successful responses, I don't think the character limit is the cause, since if the JSON got truncated, the request should fail.

After I release the image compression code, we'll continue to monitor for more examples. Thanks again!

Post Reply