I'm writing a script to automate some tests that execute Http requests. I've pasted the code and response. I think the parser is geting hung up on the colon specifying the port.
function executeRequest($url){
Write-Host "Entered executeRequest";
$webClient = New-Object net.WebClient;
$webClient.Credentials = New-Object System.Net.NetworkCredential("admin", "password");
$webClient.Headers.Add("Conten-Type", "application/json");
$webClient.UploadFile("http://127.0.0.1:5984/my_couch_collection", "D:\myFile.json");
}
The code errors out:
> Exception calling "UploadFile" with "2" argument(s): "An exception
> occurred during a WebClient request." At
> D:\staging\scripts\_0001CreateFolderStructure.ps1:8 char:23
> + $webClient.UploadFile <<<< ("http://127.0.0.1:5984/source_data", "D:\myFile.json");
> + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
> + FullyQualifiedErrorId : DotNetMethodException
I've looked at a dozen tutorials but each one does this differently however all attempts have resulted in some sort of issue referencing the ':' character.