From 5def8058cd06283c81b27468df1625cddd3b8afa Mon Sep 17 00:00:00 2001 From: Debora Crescenzo Date: Wed, 5 Feb 2025 13:10:41 +0000 Subject: [PATCH] MT#62025 Add multipart/form-data to api/faxes req Revert original code and just add missing header. Change-Id: If109b4ecc3810aad7cae5b8dc1b0dd87a7d6e325 (cherry picked from commit 3daeb267bb1c8838d6d7aaa06478c9ae067ea4f9) (cherry picked from commit 9fd654638af162ffa83354b44c946503154b5426) --- src/api/communication.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/api/communication.js b/src/api/communication.js index f7c88eb9..e5350a82 100644 --- a/src/api/communication.js +++ b/src/api/communication.js @@ -1,12 +1,18 @@ +import _ from 'lodash' import { post } from 'src/api/common' export async function createFax (options) { - if (options.faxfile === null) { - delete options.faxfile + const formData = new FormData() + const fields = _.clone(options) + delete fields.faxfile + const json = JSON.stringify(fields) + formData.append('json', json) + if (options.faxfile) { + formData.append('faxfile', options.faxfile) } - return await post({ resource: 'faxes', - body: options + headers: { 'Content-Type': 'multipart/form-data' }, + body: formData }) }