Multipart/form-data 1006 error with Marketo bulk lead import

Hello there,

Describe the issue/error/question

I’m unable to send a csv via multipart/form-data in the http-request node to Marketo’s Bulk API import endpoint.

I’ve also tried using this solution: Upload File: Multipart-formdata - Questions - n8n in a Function node but my JS probably isn’t good enough to adapt for my purposes because I don’t even get a payload response.

What is the error message (if any)?

With the http-request node I get a 1006 error saying “Header field ‘email’ not found”. Meaning the headers on my csv don’t match the API name of my corresponding Marketo fields. That is definitely not the case because 1) the REST name of the field is “email” and the SOAP name is “Email” (tried both versions) 2) same request works in Zapier.

I have to think it’s a MIME formatting issue somehow but I’m pretty lost how it’s going wrong.

Please share the workflow

Share the output returned by the last node

The output is error 1006 mentioned above. The expected output should be something like:
{
“requestId”: “d01f#15d672f8560”,
“result”: [
{
“batchId”: 3404,
“importId”: “3404”,
“status”: “Queued”
}
],
“success”: true
}

Thank you very much for for your help.

Hey @Harry_Small,

Welcome to the community :tada:

It looks like the error is coming back from Marketo and it appears to be a fairly clear one which is handy.

It might be worth sending the file to a different service just to make sure it is ok but it sounds like the issue is on the other side when they try to read it.

I don’t have a Workato account but can you share a dummy version of your file?

Sure, thanks for replying so quickly.

Test file.

Hey @Harry_Small,

Out of interest when using the Write option what data are you sending in? I am thinking the write data is not actually writing anything so it is just an empty file being sent. As a quick test can you this one and update the HTTP Request node to point to Marketo.

Hey Jon,

I think this is a quirk of the Google Drive API somehow. To reproduce the same behaviour I see from the spreadsheet node this slightly nuts setup will do it. Then I get my 1006 error.

UPDATE: In fact, this does not work in Zapier either so I think it’s an issue on the Marketo end not n8n’s, I was wrong. The process that was working in Zapier was an asset creation workflow which is a different endpoint, although still multipart/form-data. I’ll see if I can find a solution on the Marketo end and post back if I can solve it. Sorry about that.

Hey @Harry_Small,

That is likely because no data is actually being sent. You wouldn’t need the write to file from the Spreadsheet node just before the HTTP Request node if you are reading it and I suspect it is the output from that causing the issue.

I’m not sure tbh. Given the error references a header field in the csv (namely “email”), it seems like the file is being sent. Also, that was just using drive for example purposes, in fact I’m converting to csv from a workflow that pulls lead data from Marketo and Elasticsearch and reconciles on a specific ID. So I just have this data as items in the flow which I then write to a csv. I just uploaded the file to Drive as a way to share it.

Hey @Harry_Small,

When I ran your example against another service it came back with an empty file so I am fairly sure that is why it is saying the field isn’t there.

If you download the file from the Write to File output is it empty?

This is what I send basically:

Webhook.site - Test, process and transform emails and HTTP requests

I can definitively say I’m able to download the csv with no issues. I think it was just because I shared the file via Google drive that you are seeing no file. The Marketo message is reading the csv, identifying the column “email” and then not able to reconcile that column name with a corresponding marketo field, which is nuts because obviously email is a default field. I think it’s something to do with the MIME output, but could well be this is a Marketo issue, I’m asking in the forums over there and will post back if I get a resolution.

1 Like

Hey @Harry_Small,

Does the earlier example work so straight from GDrive to Marketo?

Straight from google drive does not work - but I’m keen to emphasise that this is not replicating what I see in my actual workflow which does supply a downloadable file from the spreadsheet node. I have also tested in Zapier from a OneDrive hosted file and get the exact same 1006 error message.

Hey @Harry_Small,

I get that just wanted to rule something out, I will do a quick test in a bit with the curl command they have to see what we can get from it.

Hi @Jon

So I’m 85% certain the issue is being caused by BOM in my csv headers. So my header “email” is actually ‘\EF\BB\BFemail’, it just doesn’t display in the error message of course. Is there a way to strip that from the csv, or otherwise update the body of the http-request node with the csv data?

UPDATE: I can confirm that in Zapier if I just paste in a csv formatted string rather than using the binary data from the csv then I can successfully create a bulk import update job. So that does seem to be the issue.

Is there any way to populate the body of the http-request with just a big ol’ comma delimited string with carriage returns. I’ve tried that using a raw body and setting the mime type to multipart/form-data but I’m getting 611 errors. In Zapier I can just format my text and call it into the body, must be possible right?

Stripping out the BOM in an expression with .replace() also doesn’t work so I’m really quite stuck now. The rest of my workflow does all the lovely looping etc. I can’t do in Zapier, but I’m falling at the final hurdle. I also can’t access community nodes because I’m in the cloud version so the textManipulator node is also not an option :frowning:

Hey @Harry_Small,

You could read the file then use the node output data in an HTTP Request node but you may have the same issue.

How is this file being generated? It could be that a solution is to read the file again and select the utf8 option (if there is one I am not in front of n8n right now) that should then ignore bom.

Hi @Jon,

The file is just generated from a spreadsheet node which I write from the flow itself, so it’s just a json I’ve formatted from item list nodes. So I can generate the content for the request body any way I like, I just did it this way because it seemed like I needed binary data to send a multipart/form-data request. Doesn’t even have to be a file if that’s not the best way to do it.

Thanks for the suggestion, I’ll gave a go.

Hey @Harry_Small,

If it doesn’t need to be written to a file what about using the Move Binary Data node to go from JSON to binary?

Maybe that will do the trick.

Okay but then I end up with a bunch of files like this:

And the format is like a row of split up json:
image

I can aggregate the data to get one file but then it’s one massive row with the format above.

Is there a way to create the binary file with the names as headers and the values as rows?

I think I might be confusing things with all my screenshots. At bottom what I need is csv formatted binary data without BOM. So comma delimited and carriage returns for new lines. The reason I used the spreadsheet node is that it quickly gave me that format. If I can do that with the Move Binary Data node that’s awesome but for now the resulting format might be a csv, but it isn’t placing my names and headers and my values as rows like the spreadsheet did so neatly. So then of course Marketo is unable to reconcile my data with the lead data table.