Hi,
Am trying to execute the following script in my windows power shell, but keep running into this error.
Can somebody help please?
$c1=$args[0]
$path=$args[1]
$cert=$args[2]
$p=$args[3]
$peid=$args[4]
$a2="AccountFN"
$body6="{`"provider`": {`"href`":`""+$path+"/providers/1`"},`"id`": `"$peid`",`"name`": `"+$a2+"`,`"description`": `"+$a2+"`}"
$r=Invoke-WebRequest -uri "$path/tenants/$c1/projects/$p/accounts" -Headers $headers -Certificate $cert -ContentType application/json -Method POST -Body $body6
Am using the Invoke-WebRequst to call an API which has both credential based authentication and SSL based authentication.
Am i doing something wrong?
Error Obtained:
Invoke-WebRequest : You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.At C:\Windows\Temp\PO_WorkingDir_a432e8d1-d685-45e2-926d-351440a713ff\PO_PSScript_a432e8d1-d685-45e2-926d-351440a713ff.ps1:16 char:4+ $r=Invoke-WebRequest -uri "$path/tenants/$c1/projects/$p/accounts" -Headers $hea ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-WebRequest], ProtocolV iolationException + FullyQualifiedErrorId : System.Net.ProtocolViolationException,Microsoft. PowerShell.Commands.InvokeWebRequestCom