I'm trying to import CSV files with the /crm/v3/imports endpoint, without any success so far. I've read thoroughly the issue here and some others, but still I can't find a way to make it work. As mentionned by @JakeBreaksStuff I'm surprised by the lack of documentation, and I would also add that a few hints in the HTPP response ("Bad request" really don't help) would be really helpful (even more than a documentation !).
At first I had 415 errors and now 400, can you confirm me I'm still on the right way ? 🙂
I'm not sure how to send the files param. nodejs form-data does not accept arrays, so I try without array, or with files[] or files[0] or files with JSON.stringify([file...]) but no solution worked, always get a 400 Bad Request.
Also I have to stringify the importRequest object as form-data does not work with nested object (issue here).
Thus I'm not sure where's my issue : the files param ? the importRequest param ? something wrong in my column mapping vs CSV ? I've checked and dumped formData several times to be sure 😕 Again, giving a hint in the HTTP response data would really help...
Found my issues by analysing the request of the hubspot package... The boundary parameter was missing in the content-type. I tried earlier with form.getHeaders() but removed it as somehow I did not get the multipart-form-data, probably I messed up on something. The header should look like this :
Found my issues by analysing the request of the hubspot package... The boundary parameter was missing in the content-type. I tried earlier with form.getHeaders() but removed it as somehow I did not get the multipart-form-data, probably I messed up on something. The header should look like this :
I've been trying with the hubspot-api-nodejs package, following this example, and reading the implementation. Hourra 🎉, I managed to have it worked... I also had to remove the full path in the importRequest/files/fileName property and put the file name only (contrary to what's been mentionned in another post).
So, now I'm sure my importRequest config and CSV file are OK, I'm going to investigate why my request with axios does not work (the hubspot-api-nodejs package uses request, which seems deprecated now).
I'm back on it (had to pause for an emergency); unfortunately I'm still having issues yes. I found a little mistake in my code (missing encoding param in the first readFileSync, thus csvFile was not correct), but still I get 400 errors. I've dumped formData and it looks fine. Can you confirm 400 code is an error in the content of the CSV or columnMapping itself ? Or do I have an issue with the request itself (as I said, I'm not sure the way the files param should be sent).
Do you have any working example with NodeJS ? I've read this thread also but it seems outdated (mentionning application/x-www-form-urlencoded instead of multipart/form-data as more recent ones insist on).