# API Issues with XFDF Merge Endpoint: 500 Internal Server Error and 502 Bad Gateway

**URL:** <https://pdfjs.community/t/api-issues-with-xfdf-merge-endpoint-500-internal-server-error-and-502-bad-gateway/3532>\
**Category:** Bug Reports\
**Tags:** pdfjs-express\
**Created:** [November 27, 2024, 11:49am UTC](https://pdfjs.community/t/api-issues-with-xfdf-merge-endpoint-500-internal-server-error-and-502-bad-gateway/3532 "2024-11-27T11:49:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![devops1](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@devops1](https://pdfjs.community/u/devops1)\
**Post date:** [November 27, 2024, 11:49am UTC](https://pdfjs.community/t/api-issues-with-xfdf-merge-endpoint-500-internal-server-error-and-502-bad-gateway/3532/1 "2024-11-27T11:49:00Z")

</div>

We are encountering persistent issues with the XFDF merge API endpoint:

**Endpoint:** `https://api.pdfjs.express/xfdf/merge`  
**HTTP Method:** `POST`

### **Details:**

- **Error on macOS:**

- **Error on Windows:**

### **Key Observations:**

- The endpoint was functioning as expected until recently.
- No changes were made to our implementation before the errors began occurring.

### **Steps to Reproduce:**

1. Send a `POST` request to the endpoint: `https://api.pdfjs.express/xfdf/merge`.
2. On macOS, observe the _500 Internal Server Error_ with the mentioned message.
3. On Windows, observe the _502 Bad Gateway_ response.

### **Expected Behavior:**

The API should process the POST request and return a successful response.

### **Actual Behavior:**

The API fails with error responses as described above, which prevents us from merging XFDF data—a critical function for our application.

### **Attachments:**

- Screenshot of the 500 error on Mac  

- Screenshot of the 502 Bad Gateway error on Windows.

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [November 27, 2024, 6:13pm UTC](https://pdfjs.community/t/api-issues-with-xfdf-merge-endpoint-500-internal-server-error-and-502-bad-gateway/3532/3 "2024-11-27T18:13:32Z")

</div>

Hi there,

Based on the error code you are seeing, this is related to a license error.

> **[PDF.js Express API Errors | Documentation](https://pdfjs.express/documentation/utils/errors)**

Can you see if the issue persists when you do not provide a license key?  
If you are using the Express Rest Utility API, you can use the method here:  
[https://pdfjs.express/api/utils/](https://pdfjs.express/api/utils/)

Could you please check your express dashboard to see if there’s an issue with your billing portal?

Best regards,  
Kevin

---

<div class="post-metadata">

**Author:** ![devops1](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@devops1](https://pdfjs.community/u/devops1)\
**Post date:** [December 2, 2024, 1:31pm UTC](https://pdfjs.community/t/api-issues-with-xfdf-merge-endpoint-500-internal-server-error-and-502-bad-gateway/3532/4 "2024-12-02T13:31:20Z")

</div>

Hi @kkim,

Thanks for your response! We checked the billing portal, and everything seems to be working correctly on our end.

When we don’t provide the license key, we encounter a 502 Gateway Timeout instead of the 500 error. However, with the license key (which is valid and properly configured), the 500 error still occurs.

It seems this issue is specific to a particular document or form, as other documents/forms work fine. Could you please help us identify what might be causing this?

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [December 2, 2024, 7:07pm UTC](https://pdfjs.community/t/api-issues-with-xfdf-merge-endpoint-500-internal-server-error-and-502-bad-gateway/3532/5 "2024-12-02T19:07:00Z")

</div>

Hi there,

If this is happening to a specific file, then it may be larger than 5.5MB, as indicated in the body params here:

> **[Set XFDF using the Express REST API | Documentation](https://pdfjs.express/documentation/utils/set#body-params)**

Best regards,  
Kevin

---

<div class="post-metadata">

**Author:** ![devops1](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@devops1](https://pdfjs.community/u/devops1)\
**Post date:** [December 5, 2024, 2:22pm UTC](https://pdfjs.community/t/api-issues-with-xfdf-merge-endpoint-500-internal-server-error-and-502-bad-gateway/3532/6 "2024-12-05T14:22:34Z")

</div>

Hi @kimm ,

Thank you for pointing that out. However, the file in question is around 300 KB, so it is well below the 5.5 MB limit mentioned. Could there be another reason for the issue? Please let me know if there’s anything specific you’d like me to check.

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [December 9, 2024, 4:31pm UTC](https://pdfjs.community/t/api-issues-with-xfdf-merge-endpoint-500-internal-server-error-and-502-bad-gateway/3532/7 "2024-12-09T16:31:45Z")

</div>

Hi there,

Could you please share the input file used? Does it show any errors when loading the PDF in another file reader?

Best regards,  
Kevin
