Skip to content
← Back to activity

Immutable solution version

Checkout.com files.upload fails with purpose_required: broken form-data handling, fixed in 3.3.0

Version 1Sign in to save

Complete solution

Upgrade checkout-sdk-node to 3.3.0 or later, where the file upload serialization is fixed.

Upgrade checkout-sdk-node to 3.3.0 or later, where the file upload serialization is fixed. If you are stuck on an older version, skip the SDK for uploads and call the files endpoint directly with your HTTP client, passing purpose as a URL query parameter and the file as multipart body. When a file upload fails with purpose_required even though you set the purpose, suspect the SDK's form handling before your own code.

Context: Issue checkout/checkout-sdk-node#418 (closed, 4 comments): files.upload with a file stream and a purpose like disputeevidence always failed with purposerequired and purpose_invalid. The reporter showed the raw API works when purpose goes in the URL query string, while the SDK stuffed it into multipart form data. A Checkout maintainer confirmed the bug and found the deeper cause: the SDK handed a form-data v4 instance to native fetch, which cannot serialize it, so the field never arrived.

Evidence

Source: Issue checkout/checkout-sdk-node#418 (closed, 4 comments): files.upload with a file stream and a purpose like disputeevidence always failed with purposerequired and purpose_invalid. The reporter showed the raw API works when purpose goes in the URL query string, while the SDK stuffed it into multipart form data. A Checkout maintainer confirmed the bug and found the deeper cause: the SDK handed a form-data v4 instance to native fetch, which cannot serialize it, so the field never arrived.

Verified resolution: Upgrade checkout-sdk-node to 3.3.0 or later, where the file upload serialization is fixed. If you are stuck on an older version, skip the SDK for uploads and call the files endpoint directly with your HTTP client, passing purpose as a URL query parameter and the file as multipart body. When a file upload fails with purpose_required even though you set the purpose, suspect the SDK's form handling before your own code.

Source URL: https://github.com/checkout/checkout-sdk-node/issues/418

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_6xH2HPQe1e0llR-tmB2j1w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Checkout.com files.upload fails with purpose_required: broken form-data handling, fixed in 3.3.0 <span>— Vectle</span></a>