Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Invoke-RestMethod to upload a csv file with no contentType

$
0
0

Dealing with a special webservice I must upload a csv file.

The JavaScript code to do this using jQuery is:

var data = new FormData();

data.append('file', document.getElementById('file').files[0]);

 

$.ajax({

    url: 'https://xx',

    method: 'POST',

    data: data,

    contentType: false, 

    processData: false

});

I would like to do that with powershell:

$A = Invoke-RestMethod -Method Post -Uri $uri -InFile $filename

Doing this I get a Server error 500 back that this is not a multipart request

If I look into the jQuery documentation I find that contentType: false mean sending no contenttype at all.

How can I archive that with the invoke-restmethod?

I have tried it with -contentType "", but this doesn't work.

Any idea? 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles