fix(ancpi): use form-data multipart for saveProductMetadataForBasketItem

Angular uses doPostAsFormMultipart — the save endpoint requires
multipart/form-data, not application/x-www-form-urlencoded.
Install form-data package and restore multipart upload.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-23 02:33:30 +02:00
parent fd86910ae3
commit c452bd9fb7
3 changed files with 9 additions and 7 deletions
@@ -19,6 +19,7 @@ import axios, { type AxiosInstance } from "axios";
import crypto from "crypto";
import { wrapper } from "axios-cookiejar-support";
import { CookieJar } from "tough-cookie";
import FormData from "form-data";
import type {
EpayCartResponse,
EpaySearchResult,
@@ -399,18 +400,17 @@ export class EpayClient {
configurationUrl: "http://www.google.com",
};
// Use URLSearchParams instead of multipart FormData
// (axios + cookie-jar has issues with native FormData)
const form = new URLSearchParams();
form.set("reqType", "saveProductMetadataForBasketItem");
form.set("productMetadataJSON", JSON.stringify(metadata));
// Must use multipart/form-data (Angular uses doPostAsFormMultipart)
const form = new FormData();
form.append("reqType", "saveProductMetadataForBasketItem");
form.append("productMetadataJSON", JSON.stringify(metadata));
const response = await this.client.post(
`${BASE_URL}/EpayJsonInterceptor.action`,
form.toString(),
form,
{
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
...form.getHeaders(),
"X-Requested-With": "XMLHttpRequest",
},
timeout: DEFAULT_TIMEOUT_MS,