It looks like you're on the right track with using the HubSpot API and the `form-data` library to upload a file. However, there are a few things that could be causing issues with your code. First, make sure that you have the correct folder ID specified in `formData.append("folderId", '<folderID>');`. You can find the folder ID by going to the file manager in your HubSpot account and selecting the folder that you want to upload to. The folder ID will be in the URL, after the `folderId=` parameter. Second, it's important to set the `Content-Type` header for the `formData` object. You can do this using `formData.getHeaders()`, which will return an object with the necessary headers. You can then pass this object to the `headers` option of the `hubspot.apiRequest()` function. Finally, make sure that your HubSpot API key is valid and has the necessary permissions to upload files. Here's an updated version of your code with these changes:
sendResponse({ body: { message: 'An error occurred while uploading the file.', error: errorMessage, }, statusCode: 500, }); } };
Make sure to replace `<folderID>` with the actual folder ID, and `'myFile.png'` with the actual filename of the file you're uploading. Let me know if this helps!
Please mark it as SOLUTION ACCEPTED if you like the solution & Upvote.