Skip to main content
October 1, 2015
Question

Curl works, attempting it programmatical. thoughts?

  • October 1, 2015
  • 2 replies
  • 1269 views

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 ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Kenny_Elkington
Adobe Employee
Adobe Employee
October 1, 2015

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-restmethod ), 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
October 1, 2015

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...