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:
Generated
+1
@@ -15,6 +15,7 @@
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"docx": "^9.6.0",
|
||||
"form-data": "^4.0.5",
|
||||
"jspdf": "^4.2.0",
|
||||
"jszip": "^3.10.1",
|
||||
"lucide-react": "^0.564.0",
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"docx": "^9.6.0",
|
||||
"form-data": "^4.0.5",
|
||||
"jspdf": "^4.2.0",
|
||||
"jszip": "^3.10.1",
|
||||
"lucide-react": "^0.564.0",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user