Upload files to website with curl using POST method

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.

Hi, welcome back to the forum. What makes you think anything is wrong? Http status code 200 is a success code.

You are right, but i want to upload a file (dummy.properties) to this url -
https://example.com/xxxxxx?cmd=upload.
When i play the script, i can’t upload the file with this script on this url.
When I start the script in linux environment, it’s work and I can upload file to the url. I use this command:

curl --user $username:$password --request POST "$url" --form "file=@$path"  --form  "desc=$ver"