Good afternoon,
I’m trying to add an attachment to an item using the orderForm API as shown below:
URL: /api/checkout/pub/orderForm/${response.orderFormId}/items/${itemCustom}/attachments/GiftLabelNew
However, it always returns that the key I’m trying to insert is invalid, with the message
“The key giftlabelnew of the attachment is invalid”
In the payload I have the following structure:
{content: {,…},…} content : {,…} giftlabelnew : "{\"produtoOrigem\":\"35646\",\"fundo\":\"\",\"fonte\":\"Johnnie Walker\",\"linha01\":\"Você é \",\"linha02\":\"Um Super Pai\",\"fraseCustom\":\"sim\"}" expectedOrderFormSections : ["items", "totalizers", "clientProfileData", "shippingData", "paymentData", "sellers", "messages",…] 0 : "items" 1 : "totalizers" 2 : "clientProfileData" 3 : "shippingData" 4 : "paymentData" 5 : "sellers" 6 : "messages" 7 : "marketingData" 8 : "clientPreferencesData" 9 : "storePreferencesData" 10 : "giftRegistryData" 11 : "ratesAndBenefitsData" 12 : "openTextField" 13 : "commercialConditionData" 14 : "customData" noSplitItem : true
And in my code I implement it as follows in React:
fetch(
`/api/checkout/pub/orderForm/${response.orderFormId}/items/${itemCustom}/attachments/GiftLabelNew`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
content: { "GiftLabelNew":""+JSON.stringify(attachmentContent)+"" },
expectedOrderFormSections: [
'items',
'totalizers',
'clientProfileData',
'shippingData',
'paymentData',
'sellers',
'messages',
'marketingData',
'clientPreferencesData',
'storePreferencesData',
'giftRegistryData',
'ratesAndBenefitsData',
'openTextField',
'commercialConditionData',
'customData',
],
noSplitItem: true,
}),
}
)
.then((response) => response.json())
.then((data) =>{ console.log("Response After Attachment",data)})
.catch(err => console.error(err));
What is the correct JSON structure for adding information to the attachment field contained in the item? Could you help me?
Thanks in advance