Hi team, I am trying trying to use formData to send a file to SSD on Alpha. But form data is always sent as an empty object to BFF. Can anyone assist?
6 Likes
@Irfan_Ali @vaibhav @gaurav.pandey can you please help
2 Likes
@oboikanyego can you attach screenshots of how you configured it?
4 Likes
that our config alpha
3 Likes
For now, FormData is not supported in API requests.Please raise a support request. As a workaround, you can use the custom code provided below.
const options = {
headers: {
'Content-Type': 'multipart/form-data',
}, // headers
path: 'path', // API route relative to baseUrl
method: 'POST', // HTTP method
baseUrl: {"type":"string","value":'your_baseUrl'}, // baseUrl
apiAuth: 'apiAuth', // Placeholder for auth token
body: "body", // payload
};
const file = new FormData()
file.append('path', options.path);
file.append('headers', JSON.stringify(options.headers));
file.append('method', options.method);
file.append('url', JSON.stringify(options.baseUrl));
file.append('isFormData', 'true');
file.append('apiAuth', JSON.stringify(options.apiAuth));
file.append('body', JSON.stringify(options.body));
/**
* Sends a multipart/form-data HTTP request.
*
* @param {string} baseUrl - The API endpoint to send the request to.
* @param {file} formData - The file object containing request payload.
* @param {boolean} isFormData - Indicates whether the payload is FormData.
*/
await ap.http(options.baseUrl, file, true);
Let me know if you need help using this in your case.
.
6 Likes
Still getting some issue on this,is there something i am missing here:
const options = {
headers: {
'Content-Type': 'multipart/form-data',
}, // headers
path: 'end-point', // API route relative to baseUrl
method: 'POST', // HTTP method
baseUrl: 'my-base-url', // baseUrl
apiAuth: null, // Placeholder for auth token
body: "", // payload
};
console.log('options:', options);
/**
* Sends a multipart/form-data HTTP request.
*
* @param {string} baseUrl - The API endpoint to send the request to.
* @param {file} formData - The file object containing request payload.
* @param {boolean} isFormData - Indicates whether the payload is FormData.
*/
await ap.http(options.baseUrl, page.file, true);
4 Likes
Thankyou @Irfan_Ali ![]()
2 Likes


