Hello,
I want to upload multi files to web site with power shell. Using this script - [Upload file with powershell · GitHub].I tried to upload one file but not works for me. I modify the code using method POST:
$publishUrl="https://example.com/xxxxxx?cmd=upload"
$packageName = "C:\Users\xxxxx\Desktop\xxxxx\dummy.properties"
$username="xxxxx"
$password="xxxxxxx"
$params = @{
UseBasicParsing = $true
Uri = $publishUrl
Method = "POST"
InFile = $packageName
Headers = @{
ContentType = "application/json"
Authorization = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$username`:$password")))"
}
Verbose = $true
}
Invoke-WebRequest @params
When start the script I get the following response:
DETAILED: POST https://example.com/xxxxxx?cmd=upload with -1-byte
payload
DETAILED: received 0-byte response of content type
StatusCode : 200
StatusDescription :
Content : {}
RawContent : HTTP/1.1 200
Strict-Transport-Security: max-age=31536000;includeSubDomains
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
vary: Origin
Access-Contro...
Headers : {[Strict-Transport-Security, max-age=31536000;includeSubDomains], [X-Frame-Options, SAMEORIGIN],
[X-Content-Type-Options, nosniff], [X-XSS-Protection, 1; mode=block]...}
RawContentLength : 0
What is wrong. I tried others command, but not work to me.
Thank you.