CURL pass, but Invoke-RestMethod fails for POST - Method not allowed Error

Hi,

I want to upload JSON file to artifactory platform. With curl from PowerShell it goes well and file is uploaded succesfully:

curl -H ‘X-JFrog-Art-Api:AKC’ -T test1.json https://artifactory.dev/artifactory/configurations/test1.json

But if I try to upload the same file with same key on the same path it returns error:
Invoke-RestMethod: Response status code does not indicate success: 405 (Method Not Allowed).

This is how I try it:
$header = @{“X-JFrog-Art-Api” = “AKC”}
$jsonFile=Get-Content -Raw -Path C:\Users\e5614274\Downloads\test1.json

Invoke-RestMethod -Uri "https://artifactory.dev/artifactory/configurations/test1.json" -Headers $header -Method POST -Body $jsonFile -ContentType 'application/json'

But POST is certainly allowed since I succeed to upload using the CURL.
Can someone please tell me what I am doing wrong?
Thank you in advance for helping!!!

Hello VeljkoShell,
In curl -T/–upload-file - transfers the specified local file to the remote URL.

For the Invoke-RestMethod try to use-InFile parameter, which gets the content of the web request from a file, as Get-Content returns a collection of objects, each of which represents a line of content.

Hope that helps.

Maybe your method needs to be PUT.