You may be able to use your existing web service using the Invoke-RestMethod , but it can take two separate calls. For both calls, you probably need to say -Method Post . It can be done using WebClient, but the cmdlet may be easier to describe. I didn't actually try this, but it could look something like this:
Invoke-RestMethod -Method Post $loginPage -SessionVariable webSession -Body "..." Invoke-RestMethod -Method Post $uploadPage -WebSession $webSession -Body "..."
For the first call, you specify the URL of the login page and simulate logging into web forms by specifying the username and password in parmeter -Body and use -SessionVariable to capture and store the context to create the next authenticated request.
In the second request, you use the data load URL, the -WebSession parameter to provide the context set by the first request, and -Body to load the CSV. Note that you need the dollar sign in the webSession variable in the second, but not the first.
Of course, you will need to save the username / password for automation in order to use it somewhere, but it is always necessary for automatic automation. A possible approach to mitigate this might be to use credentials based on a client certificate, and not for web form authentication.
Burt_harris
source share