Curl works, attempting it programmatical. thoughts?

Anonymous
Not applicable

Curl works, attempting it programmatical. thoughts?

using this (not as is, $parameters are filled in as it runs:

c:\day1\i386\curl.exe -i -F format=$format -F file=@$file -F access_token=$token $hostw/bulk/v1/leads.json -F listId=$list

I am able to upload lead data into Marketo via the CURL command above  The $variables are populated during execution.  Works fine.

below is WHAT i think it should be for powershell to upload the same file, or close to this.

Invoke-RestMethod -Uri "$hostw/bulk/v1/leads.json?access_token=$token" -Method Post -InFile $file  -ContentType 'multipart/form-data'

is that even possible to reproduce ?

2 REPLIES 2
Kenny_Elkington
Marketo Employee

Re: Curl works, attempting it programmatical. thoughts?

I think this should work with your given IRM( based on what's given here http://stackoverflow.com/questions/22491129/how-to-send-multipart-form-data-with-powershell-invoke-r... ), but the format param is required for import, so your URI needs "&format=<listFormat>.  Ideally you would do this as part of the request body, but I'm coming up dry on finding an easy way to comingle file and non-file content in a powershell multipart request.

SanfordWhiteman
Level 10 - Community Moderator

Re: Curl works, attempting it programmatical. thoughts?

Alex, in all seriousness, any time spent bending PS to your will would be better spent either retrenching with batch file syntax or using something like JJS or NodeJS (command-line JS). I feel the rewards for your dev skills will be worth the struggle. My $0.02...