Hello, I would check the following things:
1: Confirm that that Content-Type header is handled correctly
The most common problem when using axios with form-data is trying to set the Content-Type header manually — or not letting form-data handle it properly.
You’re already using form.getHeaders() — good! But here’s the nuance:
headers: { Authorization: `Bearer ${process.env.PRIVATE_APP_TOKEN}`, …form.getHeaders(), // this sets proper Content-Type boundary },
I would make sure:
- You’re not setting Content-Type manually elsewhere, especially with a plain ‘multipart/form-data’ string.
- profile_photo.buffer is actually a Buffer, not a string or corrupted stream.
2: HubSpot expects file to be a Buffer, not a stream
When using serverless functions, profile_photo.buffer is sometimes undefined or misread — especially in context.files.
Validate that profile_photo exists and has the right structure:
if (!profile_photo || !profile_photo.buffer || !profile_photo.originalname) {
throw new Error(“Missing uploaded file or filename”); }
Then ensure you’re passing the buffer with the correct filename and MIME type:
form.append(‘file’, buffer, {
filename: profile_photo.originalname, contentType: profile_photo.mimetype || ‘application/octet-stream’, });
Let me know if this helps, or if you have any other questions!
Was I able to help answer your question? Help the community by marking it as a solution.
| Brandon Woodruff Senior Software Developer @ PearagonStill have questions? Reach out at brandon@pearagon.com ![]() |

