I checked your issue and I’m not sure where the request format you used came from. According to the official documentation (Upload file – HubSpot Docs), you should be using multipart/form-data.
Currently, you’re sending raw JSON data, which oddly seems to work in some cases. Maybe due to an older specification that I might have missed.
Try with the following format, which follows the official API reference:
I attempted to upload a file using a serverless function with the "multipart/form-data" content type, but the request returned a 415 Unsupported Media Type error.
I also trie d to upload a file in the API developer tools, but got the server error again.
The 415 error indicates that there’s still an issue with the data format. Please make sure you’ve included the Content-Type: multipart/form-data header in your request.
The issue here is the file is being sent to a serverless function to upload. Serverless function payloads are limited to 6MB (undocumented as far as I can tell).
If you were to upload a document directly via the files API you won’t hit that limit - documented file upload limits apply (e.g. via postman).
You cannot upload directly to the files API from a browser as the endpoint requires a secret which should not be stored on the client.
The options are:
- Sending the document as a field in a form (in this case it wont work as we need the files ID),
- or; sending the upload request from a proxy service, which in turn uploads the file via the files API as per usual.